]> granicus.if.org Git - vim/commitdiff
patch 8.2.1844: using "q" at the more prompt doesn't stop a long message v8.2.1844
authorBram Moolenaar <Bram@vim.org>
Tue, 13 Oct 2020 20:15:56 +0000 (22:15 +0200)
committerBram Moolenaar <Bram@vim.org>
Tue, 13 Oct 2020 20:15:56 +0000 (22:15 +0200)
Problem:    Using "q" at the more prompt doesn't stop a long message.
Solution:   Check for "got_int". (closes #7122)

src/message.c
src/testdir/dumps/Test_quit_long_message.dump [new file with mode: 0644]
src/testdir/test_messages.vim
src/version.c

index c52795286b322cb0e3dfced2c2374ebcbafdead6..42641211ce639d4163dd97f6bea2fd99b5a219b3 100644 (file)
@@ -1551,6 +1551,10 @@ msg_outtrans_len_attr(char_u *msgstr, int len, int attr)
     char_u     *s;
     int                mb_l;
     int                c;
+    int                save_got_int = got_int;
+
+    // Only quit when got_int was set in here.
+    got_int = FALSE;
 
     // if MSG_HIST flag set, add message to history
     if (attr & MSG_HIST)
@@ -1568,7 +1572,7 @@ msg_outtrans_len_attr(char_u *msgstr, int len, int attr)
      * Go over the string.  Special characters are translated and printed.
      * Normal characters are printed several at a time.
      */
-    while (--len >= 0)
+    while (--len >= 0 && !got_int)
     {
        if (enc_utf8)
            // Don't include composing chars after the end.
@@ -1618,10 +1622,12 @@ msg_outtrans_len_attr(char_u *msgstr, int len, int attr)
        }
     }
 
-    if (str > plain_start)
+    if (str > plain_start && !got_int)
        // print the printable chars at the end
        msg_puts_attr_len((char *)plain_start, (int)(str - plain_start), attr);
 
+    got_int |= save_got_int;
+
     return retval;
 }
 
diff --git a/src/testdir/dumps/Test_quit_long_message.dump b/src/testdir/dumps/Test_quit_long_message.dump
new file mode 100644 (file)
index 0000000..9624747
--- /dev/null
@@ -0,0 +1,6 @@
+> +0&#ffffff0@74
+|~+0#4040ff13&| @73
+|~| @73
+|~| @73
+|~| @73
+| +0#0000000&@56|0|,|0|-|1| @8|A|l@1| 
index c575672073b91ad457ffc23095eab4df2a723e69..158e94bc5afef17d0a727c9d710962289307dc8d 100644 (file)
@@ -4,6 +4,7 @@ source check.vim
 source shared.vim
 source term_util.vim
 source view_util.vim
+source screendump.vim
 
 func Test_messages()
   let oldmore = &more
@@ -309,4 +310,20 @@ func Test_mapping_at_hit_return_prompt()
   nunmap <C-B>
 endfunc
 
+func Test_quit_long_message()
+  CheckScreendump
+
+  let content =<< trim END
+    echom range(9999)->join("\x01")
+  END
+  call writefile(content, 'Xtest_quit_message')
+  let buf = RunVimInTerminal('-S Xtest_quit_message', #{rows: 6})
+  call term_sendkeys(buf, "q")
+  call VerifyScreenDump(buf, 'Test_quit_long_message', {})
+
+  " clean up
+  call StopVimInTerminal(buf)
+  call delete('Xtest_diff_rnu')
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab
index 0e5c4df494f5de2b1561b9894f64edbf4e141b6a..c6f98c36d05b41980e83b97b3511ca8c5521e89c 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1844,
 /**/
     1843,
 /**/