changeset 29377:48b086982c01 v9.0.0031

patch 9.0.0031: <cmod> of user command does not have correct verbose value Commit: https://github.com/vim/vim/commit/9359e8a6d99fe2abfcbb9603339f1740d8870cc6 Author: zeertzjq <zeertzjq@outlook.com> Date: Sun Jul 3 13:16:09 2022 +0100 patch 9.0.0031: <cmod> of user command does not have correct verbose value Problem: <cmod> of user command does not have correct verbose value. Solution: Use the value from the command modifier. (closes https://github.com/vim/vim/issues/10651)
author Bram Moolenaar <Bram@vim.org>
date Sun, 03 Jul 2022 14:30:06 +0200
parents 1538a0d4a85e
children 2bb0b6cb903f
files runtime/doc/map.txt src/testdir/test_usercommands.vim src/usercmd.c src/version.c
diffstat 4 files changed, 44 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/runtime/doc/map.txt
+++ b/runtime/doc/map.txt
@@ -1721,10 +1721,10 @@ The valid escape sequences are
 		nothing. Supported modifiers are |:aboveleft|, |:belowright|,
 		|:botright|, |:browse|, |:confirm|, |:hide|, |:keepalt|,
 		|:keepjumps|, |:keepmarks|, |:keeppatterns|, |:leftabove|,
-		|:lockmarks|, |:noswapfile| |:rightbelow|, |:silent|, |:tab|,
-		|:topleft|, |:verbose|, and |:vertical|.
-		Note that these are not yet supported: |:noautocmd|,
-		|:sandbox| and |:unsilent|.
+		|:lockmarks|, |:noautocmd|, |:noswapfile| |:rightbelow|,
+		|:sandbox|, |:silent|, |:tab|, |:topleft|, |:unsilent|,
+		|:verbose|, and |:vertical|.
+		Note that |:filter| is not supported.
 		Examples: >
 		    command! -nargs=+ -complete=file MyEdit
 				\ for f in expand(<q-args>, 0, 1) |
--- a/src/testdir/test_usercommands.vim
+++ b/src/testdir/test_usercommands.vim
@@ -58,7 +58,10 @@ function Test_cmdmods()
   call assert_equal('lockmarks', g:mods)
   loc MyCmd
   call assert_equal('lockmarks', g:mods)
-  " noautocmd MyCmd
+  noautocmd MyCmd
+  call assert_equal('noautocmd', g:mods)
+  noa MyCmd
+  call assert_equal('noautocmd', g:mods)
   noswapfile MyCmd
   call assert_equal('noswapfile', g:mods)
   nos MyCmd
@@ -72,29 +75,43 @@ function Test_cmdmods()
   call assert_equal('silent', g:mods)
   sil MyCmd
   call assert_equal('silent', g:mods)
+  silent! MyCmd
+  call assert_equal('silent!', g:mods)
+  sil! MyCmd
+  call assert_equal('silent!', g:mods)
   tab MyCmd
   call assert_equal('tab', g:mods)
   topleft MyCmd
   call assert_equal('topleft', g:mods)
   to MyCmd
   call assert_equal('topleft', g:mods)
-  " unsilent MyCmd
+  unsilent MyCmd
+  call assert_equal('unsilent', g:mods)
+  uns MyCmd
+  call assert_equal('unsilent', g:mods)
   verbose MyCmd
   call assert_equal('verbose', g:mods)
   verb MyCmd
   call assert_equal('verbose', g:mods)
+  0verbose MyCmd
+  call assert_equal('0verbose', g:mods)
+  3verbose MyCmd
+  call assert_equal('3verbose', g:mods)
+  999verbose MyCmd
+  call assert_equal('999verbose', g:mods)
   vertical MyCmd
   call assert_equal('vertical', g:mods)
   vert MyCmd
   call assert_equal('vertical', g:mods)
 
   aboveleft belowright botright browse confirm hide keepalt keepjumps
-	      \ keepmarks keeppatterns lockmarks noswapfile silent tab
-	      \ topleft verbose vertical MyCmd
+	      \ keepmarks keeppatterns lockmarks noautocmd noswapfile silent
+	      \ tab topleft unsilent verbose vertical MyCmd
 
   call assert_equal('browse confirm hide keepalt keepjumps ' .
-      \ 'keepmarks keeppatterns lockmarks noswapfile silent ' .
-      \ 'verbose aboveleft belowright botright tab topleft vertical', g:mods)
+      \ 'keepmarks keeppatterns lockmarks noswapfile unsilent noautocmd ' .
+      \ 'silent verbose aboveleft belowright botright tab topleft vertical',
+      \ g:mods)
 
   let g:mods = ''
   command! -nargs=* MyQCmd let g:mods .= '<q-mods> '
--- a/src/usercmd.c
+++ b/src/usercmd.c
@@ -1492,10 +1492,23 @@ produce_cmdmods(char_u *buf, cmdmod_T *c
 			(cmod->cmod_flags & CMOD_ERRSILENT) ? "silent!"
 						      : "silent", &multi_mods);
     // :verbose
-    if (p_verbose > 0)
-	result += add_cmd_modifier(buf, "verbose", &multi_mods);
+    if (cmod->cmod_verbose > 0)
+    {
+	int verbose_value = cmod->cmod_verbose - 1;
+
+	if (verbose_value == 1)
+	    result += add_cmd_modifier(buf, "verbose", &multi_mods);
+	else
+	{
+	    char verbose_buf[NUMBUFLEN];
+
+	    sprintf(verbose_buf, "%dverbose", verbose_value);
+	    result += add_cmd_modifier(buf, verbose_buf, &multi_mods);
+	}
+    }
     // flags from cmod->cmod_split
     result += add_win_cmd_modifers(buf, cmod, &multi_mods);
+
     if (quote && buf != NULL)
     {
 	buf += result - 2;
--- a/src/version.c
+++ b/src/version.c
@@ -736,6 +736,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    31,
+/**/
     30,
 /**/
     29,