Commit: patch 9.2.0985: Multiline messages not visible when mapping starts cmdline
Christian Brabandt <[email protected]>
| Newsgroups | gmane.editors.vim.devel |
|---|---|
| Message-ID | <[email protected]> |
patch 9.2.0985: Multiline messages not visible when mapping starts cmdline Commit: https://github.com/vim/vim/commit/fb4866a2dd58c4479418a9aea649db786e8750c6 Author: zeertzjq <[email protected]> Date: Thu Aug 20 19:08:54 2026 +0000 patch 9.2.0985: Multiline messages not visible when mapping starts cmdline Problem: Multiline messages exceeding 'cmdheight' not visible when a mapping starts cmdline immediately after it (after 9.2.0967). Solution: Revert patch 9.2.0967 and use a different solution (zeertzjq). fixes: #21098 closes: #21101 Signed-off-by: zeertzjq <[email protected]> Signed-off-by: Christian Brabandt <[email protected]> diff --git a/runtime/doc/message.txt b/runtime/doc/message.txt index 6a39e3f01..28de28edd 100644 --- a/runtime/doc/message.txt +++ b/runtime/doc/message.txt @@ -1,4 +1,4 @@ -*message.txt* For Vim version 9.2. Last change: 2026 Feb 14 +*message.txt* For Vim version 9.2. Last change: 2026 Aug 20 VIM REFERENCE MANUAL by Bram Moolenaar @@ -854,6 +854,9 @@ and the screen is about to be redrawn: If you accidentally hit <Enter> or <Space> and you want to see the displayed text then use |g<|. This only works when 'more' is set. +Keys that have not been typed dismiss the prompt and are handled as normal +commands. + To reduce the number of hit-enter prompts: - Set 'messagesopt'. - Set 'cmdheight' to 2 or higher. diff --git a/src/message.c b/src/message.c index 1eecb053a..2a1461bba 100644 --- a/src/message.c +++ b/src/message.c @@ -1287,12 +1287,10 @@ wait_return(int redraw) c = CAR; // no need for a return in ex mode got_int = FALSE; } - else if (!stuff_empty() || !typebuf_typed()) - // When there are stuffed characters or pending mapped characters, the - // next character will dismiss the hit-enter prompt immediately. A - // stuffed character then has to be put back, while a mapped character - // may even be swallowed (e.g. "g" treated as a message-scrollback key), - // so instead just don't show the hit-enter prompt at all. + else if (!stuff_empty()) + // When there are stuffed characters, the next stuffed character will + // dismiss the hit-enter prompt immediately and have to be put back, so + // instead just don't show the hit-enter prompt at all. c = CAR; else { @@ -1348,7 +1346,7 @@ wait_return(int redraw) // at the hit-enter prompt. Use CTRL-Y, because the same is // used in Cmdline-mode and it's harmless when there is no // selection. - if (c == Ctrl_Y && clip_star.state == SELECT_DONE) + if (KeyTyped && c == Ctrl_Y && clip_star.state == SELECT_DONE) { clip_copy_modeless_selection(TRUE); c = K_IGNORE; @@ -1361,7 +1359,7 @@ wait_return(int redraw) * screen, to avoid that typing one 'j' too many makes the * messages disappear. */ - if (p_more && !p_cp) + if (KeyTyped && p_more && !p_cp) { if (c == 'b' || c == Ctrl_B || c == 'k' || c == 'u' || c == 'g' || c == K_UP || c == K_PAGEUP) @@ -1421,8 +1419,8 @@ wait_return(int redraw) if (c == K_LEFTMOUSE || c == K_MIDDLEMOUSE || c == K_RIGHTMOUSE || c == K_X1MOUSE || c == K_X2MOUSE) (void)jump_to_mouse(MOUSE_SETPOS, NULL, 0); - else if (vim_strchr((char_u *)" ", c) == NULL && c != Ctrl_C - && c != 'q') + else if (!KeyTyped || (vim_strchr((char_u *)" ", c) == NULL + && c != Ctrl_C && c != 'q')) { // Put the character back in the typeahead buffer. Don't use // the stuff buffer, because lmaps wouldn't work. diff --git a/src/testdir/test_messages.vim b/src/testdir/test_messages.vim index b628a28e8..1ab80294a 100644 --- a/src/testdir/test_messages.vim +++ b/src/testdir/test_messages.vim @@ -813,29 +813,42 @@ func Test_long_formatprg_no_hit_enter() call StopVimInTerminal(buf) endfunc -" A message shown while a mapping is still being processed must not raise a -" hit-enter prompt that eats the mapping's remaining keys. -func Test_hit_enter_no_eat_mapped_keys() +" A message shown while a mapping is still being processed must not eat the +" mapping's remaining keys. +" If a mapping starts cmdline after multiline messages exceeding 'cmdheight', +" the messages should still be visible. +func Test_hit_enter_during_mapping() CheckRunVimInTerminal let lines =<< trim END set ruler call setline(1, range(1, 20)) - " The 8-line :echo scrolls the screen and would raise a hit-enter prompt; - " the mapping then runs "gg" to move the cursor to line 1. + " The 8-line :echo leads to a hit-enter prompt. nnoremap X :echo "a b c d e f g h"<CR>gg + nnoremap :echo "a b c d e f g h"<CR>:b<Space> normal! 10G END call writefile(lines, 'XtestHitEnterMap', 'D') let buf = RunVimInTerminal('-S XtestHitEnterMap', #{rows: 10}) - call WaitForAssert({-> assert_match('10,1', term_getline(buf, 10))}) + call WaitForAssert({-> assert_match(' 10,1 ', term_getline(buf, 10))}) call term_sendkeys(buf, "X") " Without the fix the hit-enter prompt eats the mapping's "g" keys and the " cursor stays put. With the fix "gg" runs and moves the cursor to line 1. - call WaitForAssert({-> assert_match('1,1', term_getline(buf, 10))}) + call WaitForAssert({-> assert_match(' 1,1 ', term_getline(buf, 10))}) call assert_notmatch('Press ENTER', term_getline(buf, 10)) + call term_sendkeys(buf, ' ') + call WaitForAssert({-> assert_match('^:b ', term_getline(buf, 10))}) + call assert_match('^a *$', term_getline(buf, 2)) + call assert_match('^b *$', term_getline(buf, 3)) + call assert_match('^c *$', term_getline(buf, 4)) + call assert_match('^d *$', term_getline(buf, 5)) + call assert_match('^e *$', term_getline(buf, 6)) + call assert_match('^f *$', term_getline(buf, 7)) + call assert_match('^g *$', term_getline(buf, 8)) + call assert_match('^h *$', term_getline(buf, 9)) + " clean up call StopVimInTerminal(buf) endfunc diff --git a/src/version.c b/src/version.c index 7d8f14d74..535e5df2b 100644 --- a/src/version.c +++ b/src/version.c @@ -763,6 +763,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 985, /**/ 984, /**/ -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion visit https://groups.google.com/d/msgid/vim_dev/E1wx8Si-00Dyf1-CT%40256bit.org.