]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.1965: q can accidentally start recording at more prompt v9.1.1965
authorBjoern Foersterling <bjoern.foersterling@gmail.com>
Tue, 9 Dec 2025 12:27:00 +0000 (13:27 +0100)
committerChristian Brabandt <cb@256bit.org>
Tue, 9 Dec 2025 12:27:00 +0000 (13:27 +0100)
Problem:  When exiting at the end of the more prompt (at the hit enter
          prompt) by hitting q the recording mode will be started.
          (Jakub Łuczyński)
Solution: Don't add the q key to the typeahead buffer
          in the function wait_return (Bjoern Foersterling)

fixes: #2589
closes: #18889

Signed-off-by: Bjoern Foersterling <bjoern.foersterling@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
runtime/doc/message.txt
src/message.c
src/testdir/test_messages.vim
src/version.c

index 2411440f49dca10ce8eb43419976012de789919a..cbbd3f4c348caed4aa413aad8786f63b5f029b24 100644 (file)
@@ -1,4 +1,4 @@
-*message.txt*  For Vim version 9.1.  Last change: 2025 Nov 09
+*message.txt*  For Vim version 9.1.  Last change: 2025 Dec 09
 
 
                  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -848,6 +848,8 @@ and the screen is about to be redrawn:
    like pressing <Space>.  This makes it impossible to select text though.
 -> For the GUI clicking the left mouse button in the last line works like
    pressing <Space>.
+-> |q| won't start recording into a register (rationale: it is often used as
+   "quit" prompt key by users)
 
 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.
index b667625539f54a703bc3035a5a46cad9d1846e6f..4b93b248a8248bd2197e9b503ddcb765dcca13f8 100644 (file)
@@ -1414,7 +1414,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 *)"\r\n ", c) == NULL && c != Ctrl_C)
+           else if (vim_strchr((char_u *)"\r\n ", 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.
index 2dca0e36dcd53cee50818a55cf9336070d97e3fc..8fddcbc43f72533612e550a89d29eaded51056ef 100644 (file)
@@ -340,6 +340,25 @@ func Test_message_more()
   call StopVimInTerminal(buf)
 endfunc
 
+func Test_message_more_recording()
+  CheckRunVimInTerminal
+  let buf = RunVimInTerminal('', {'rows': 6})
+  call term_sendkeys(buf, ":call setline(1, range(1, 100))\n")
+  call term_sendkeys(buf, ":%p\n")
+  call WaitForAssert({-> assert_equal('-- More --', term_getline(buf, 6))})
+  call term_sendkeys(buf, 'G')
+  call WaitForAssert({-> assert_equal('Press ENTER or type command to continue', term_getline(buf, 6))})
+
+  " Hitting 'q' at the end of the more prompt should not start recording
+  call term_sendkeys(buf, 'q')
+  call WaitForAssert({-> assert_equal(5, term_getcursor(buf)[0])})
+  " Hitting 'k' now should move the cursor up instead of recording keys
+  call term_sendkeys(buf, 'k')
+  call WaitForAssert({-> assert_equal(4, term_getcursor(buf)[0])})
+
+  call StopVimInTerminal(buf)
+endfunc
+
 " Test more-prompt scrollback
 func Test_message_more_scrollback()
   CheckScreendump
index fef7febbb9fcd234c12f08ddee7acd077daf5297..beda34d85618cb269e928d85254d8dcaf4186d02 100644 (file)
@@ -729,6 +729,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1965,
 /**/
     1964,
 /**/