diff --git a/src/os_win32.c b/src/os_win32.c index edaf7cb306..6ccd185f08 100644 --- a/src/os_win32.c +++ b/src/os_win32.c @@ -4881,6 +4881,10 @@ mch_system_classic(char *cmd, int options) // Try to get input focus back. Doesn't always work though. PostMessage(hwnd, WM_SETFOCUS, 0, 0); + // To increase the chances that WM_SETFOCUS will work, run the message loop + // here. In addition, it prevents problems caused by delayed WM_SETFOCUS + // processing. + gui_mch_update(); return ret; } diff --git a/src/testdir/test_normal.vim b/src/testdir/test_normal.vim index 58c1b97832..f41ae0552c 100644 --- a/src/testdir/test_normal.vim +++ b/src/testdir/test_normal.vim @@ -4411,4 +4411,33 @@ func Test_pos_percentage_in_turkish_locale() endtry endfunc +" This test simulates the problem with gvim on Windows, observed when +" Test_normal11_showcmd in test_normal.vim is executed consecutively after +" Test_mouse_shape_after_failed_change. +" +" The problem occurred because WM_SETFOCUS was processed slowly, and typebuf +" was not empty when it should have been. +func Test_win32_gui_setfocus_prevent_showcmd() + if !has('win32') || !has('gui_running') + throw 'Skipped: Windows GUI regression test' + endif + + " WM_SETFOCUS event occurs when finish to execute filter command in gvim + exe 'silent !echo foo' + + set showcmd + 10new + call setline(1, ['aaaaa', 'bbbbb', 'ccccc']) + call feedkeys("ggl\lljj", 'xt') + + " showcmd could not be updated because events originating from WM_SETFOCUS + " were stored in typebuf at here. clear_showcmd() executed from redraw, + " will not draw the selection information unless you are in visual mode and + " typebuf is empty. + redraw! + + call assert_match('3x3$', Screenline(&lines)) + call feedkeys("\", 'xt') +endfunc + " vim: shiftwidth=2 sts=2 expandtab nofoldenable diff --git a/src/version.c b/src/version.c index 620e1a5bd9..076063b4cf 100644 --- a/src/version.c +++ b/src/version.c @@ -734,6 +734,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 50, /**/ 49, /**/