diff options
-rw-r--r-- | src/nvim/getchar.c | 20 | ||||
-rw-r--r-- | test/old/testdir/test_ex_mode.vim | 22 |
2 files changed, 34 insertions, 8 deletions
diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c index 183fd5e19f..ea541dbca4 100644 --- a/src/nvim/getchar.c +++ b/src/nvim/getchar.c @@ -2345,7 +2345,7 @@ void check_end_reg_executing(bool advance) /// K_SPECIAL may be escaped, need to get two more bytes then. static int vgetorpeek(bool advance) { - int c, c1; + int c; bool timedout = false; // waited for more than 'timeoutlen' // for mapping to complete or // 'ttimeoutlen' for complete key code @@ -2639,7 +2639,7 @@ static int vgetorpeek(bool advance) // input from the user), show the partially matched characters // to the user with showcmd. int showcmd_idx = 0; - c1 = 0; + bool showing_partial = false; if (typebuf.tb_len > 0 && advance && !exmode_active) { if (((State & (MODE_NORMAL | MODE_INSERT)) || State == MODE_LANGMAP) && State != MODE_HITRETURN) { @@ -2648,7 +2648,7 @@ static int vgetorpeek(bool advance) && ptr2cells((char *)typebuf.tb_buf + typebuf.tb_off + typebuf.tb_len - 1) == 1) { edit_putchar(typebuf.tb_buf[typebuf.tb_off + typebuf.tb_len - 1], false); setcursor(); // put cursor back where it belongs - c1 = 1; + showing_partial = true; } // need to use the col and row from above here old_wcol = curwin->w_wcol; @@ -2666,12 +2666,15 @@ static int vgetorpeek(bool advance) curwin->w_wrow = old_wrow; } - // this looks nice when typing a dead character map - if ((State & MODE_CMDLINE) && cmdline_star == 0) { + // This looks nice when typing a dead character map. + // There is no actual command line for get_number(). + if ((State & MODE_CMDLINE) + && get_cmdline_info()->cmdbuff != NULL + && cmdline_star == 0) { char *p = (char *)typebuf.tb_buf + typebuf.tb_off + typebuf.tb_len - 1; if (ptr2cells(p) == 1 && (uint8_t)(*p) < 128) { putcmdline(*p, false); - c1 = 1; + showing_partial = true; } } } @@ -2704,11 +2707,12 @@ static int vgetorpeek(bool advance) if (showcmd_idx != 0) { pop_showcmd(); } - if (c1 == 1) { + if (showing_partial == 1) { if (State & MODE_INSERT) { edit_unputchar(); } - if (State & MODE_CMDLINE) { + if ((State & MODE_CMDLINE) + && get_cmdline_info()->cmdbuff != NULL) { unputcmdline(); } else { setcursor(); // put cursor back where it belongs diff --git a/test/old/testdir/test_ex_mode.vim b/test/old/testdir/test_ex_mode.vim index a6201886aa..b30dce8630 100644 --- a/test/old/testdir/test_ex_mode.vim +++ b/test/old/testdir/test_ex_mode.vim @@ -137,6 +137,28 @@ func Test_open_command_flush_line() bwipe! endfunc +" FIXME: this doesn't fail without the fix but hangs +func Skip_Test_open_command_state() + " Tricky script that failed because State was not set properly + let lines =<< trim END + !ls + 0scìi + so! Xsourced + set t_û0=0 + v/-/o + END + call writefile(lines, 'XopenScript', '') + + let sourced = ["!f\u0083\x02\<Esc>z=0"] + call writefile(sourced, 'Xsourced', 'b') + + CheckRunVimInTerminal + let buf = RunVimInTerminal('-u NONE -i NONE -n -m -X -Z -e -s -S XopenScript -c qa!', #{rows: 6, wait_for_ruler: 0, no_clean: 1}) + sleep 3 + + call StopVimInTerminal(buf) +endfunc + " Test for :g/pat/visual to run vi commands in Ex mode " This used to hang Vim before 8.2.0274. func Test_Ex_global() |