]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.0582: Printed line doesn't overwrite colon when pressing Enter in Ex mode v9.1.0582
authorzeertzjq <zeertzjq@outlook.com>
Sun, 14 Jul 2024 08:22:54 +0000 (10:22 +0200)
committerChristian Brabandt <cb@256bit.org>
Sun, 14 Jul 2024 08:22:54 +0000 (10:22 +0200)
Problem:  Printed line no longer overwrites colon when pressing Enter in
          Ex mode (after 9.1.0573).
Solution: Restore the behavior of pressing Enter in Ex mode.
          (zeertzjq)

closes: #15258

Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/ex_docmd.c
src/testdir/test_ex_mode.vim
src/version.c

index 53f9d1af2c10643c95897231278906059cc5a241..e6200ed706201c3e6bdd3936eb9a90efd9875c0b 100644 (file)
@@ -2721,6 +2721,12 @@ ex_errmsg(char *msg, char_u *arg)
     return ex_error_buf;
 }
 
+/*
+ * The "+" string used in place of an empty command in Ex mode.
+ * This string is used in pointer comparison.
+ */
+static char exmode_plus[] = "+";
+
 /*
  * Handle a range without a command.
  * Returns an error message on failure.
@@ -2730,7 +2736,8 @@ ex_range_without_command(exarg_T *eap)
 {
     char *errormsg = NULL;
 
-    if ((*eap->cmd == '|' || exmode_active)
+    if ((*eap->cmd == '|' ||
+               (exmode_active && eap->cmd != (char_u *)exmode_plus + 1))
 #ifdef FEAT_EVAL
            && !in_vim9script()
 #endif
@@ -3212,7 +3219,7 @@ parse_command_modifiers(
                eap->cmd = orig_cmd;
     }
     else if (use_plus_cmd)
-       eap->cmd = (char_u *)"+";
+       eap->cmd = (char_u *)exmode_plus;
 
     return OK;
 }
index c4f82d33ce5e6b766a6eae91e7af4a41917c7816..a1ec15d7e252daf2c4f5d4336191160362f58d64 100644 (file)
@@ -68,7 +68,7 @@ func Test_Ex_substitute()
   CheckRunVimInTerminal
   let buf = RunVimInTerminal('', {'rows': 6})
 
-  call term_sendkeys(buf, ":call setline(1, ['foo foo', 'foo foo', 'foo foo'])\<CR>")
+  call term_sendkeys(buf, ":call setline(1, repeat(['foo foo'], 4))\<CR>")
   call term_sendkeys(buf, ":set number\<CR>")
   call term_sendkeys(buf, "gQ")
   call WaitForAssert({-> assert_match(':', term_getline(buf, 6))}, 1000)
@@ -90,8 +90,14 @@ func Test_Ex_substitute()
 
   " Pressing enter in ex mode should print the current line
   call term_sendkeys(buf, "\<CR>")
-  call WaitForAssert({-> assert_match('  3 foo foo',
-        \ term_getline(buf, 5))}, 1000)
+  call WaitForAssert({-> assert_match('  3 foo foo', term_getline(buf, 5))}, 1000)
+  call WaitForAssert({-> assert_match(':', term_getline(buf, 6))}, 1000)
+
+  " The printed line should overwrite the colon
+  call term_sendkeys(buf, "\<CR>")
+  call WaitForAssert({-> assert_match('  3 foo foo', term_getline(buf, 4))}, 1000)
+  call WaitForAssert({-> assert_match('  4 foo foo', term_getline(buf, 5))}, 1000)
+  call WaitForAssert({-> assert_match(':', term_getline(buf, 6))}, 1000)
 
   call term_sendkeys(buf, ":vi\<CR>")
   call WaitForAssert({-> assert_match('foo bar', term_getline(buf, 1))}, 1000)
index fe4badc89afb515340148fb92c2843e6d4f205a2..ab317d392714cd83289b217879b688a29cfb1eb4 100644 (file)
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    582,
 /**/
     581,
 /**/