Skip to content

Commit 9359e8a

Browse files
zeertzjqbrammool
authored andcommitted
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 #10651)
1 parent 22e7e86 commit 9359e8a

4 files changed

Lines changed: 44 additions & 12 deletions

File tree

runtime/doc/map.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1721,10 +1721,10 @@ The valid escape sequences are
17211721
nothing. Supported modifiers are |:aboveleft|, |:belowright|,
17221722
|:botright|, |:browse|, |:confirm|, |:hide|, |:keepalt|,
17231723
|:keepjumps|, |:keepmarks|, |:keeppatterns|, |:leftabove|,
1724-
|:lockmarks|, |:noswapfile| |:rightbelow|, |:silent|, |:tab|,
1725-
|:topleft|, |:verbose|, and |:vertical|.
1726-
Note that these are not yet supported: |:noautocmd|,
1727-
|:sandbox| and |:unsilent|.
1724+
|:lockmarks|, |:noautocmd|, |:noswapfile| |:rightbelow|,
1725+
|:sandbox|, |:silent|, |:tab|, |:topleft|, |:unsilent|,
1726+
|:verbose|, and |:vertical|.
1727+
Note that |:filter| is not supported.
17281728
Examples: >
17291729
command! -nargs=+ -complete=file MyEdit
17301730
\ for f in expand(<q-args>, 0, 1) |

src/testdir/test_usercommands.vim

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,10 @@ function Test_cmdmods()
5858
call assert_equal('lockmarks', g:mods)
5959
loc MyCmd
6060
call assert_equal('lockmarks', g:mods)
61-
" noautocmd MyCmd
61+
noautocmd MyCmd
62+
call assert_equal('noautocmd', g:mods)
63+
noa MyCmd
64+
call assert_equal('noautocmd', g:mods)
6265
noswapfile MyCmd
6366
call assert_equal('noswapfile', g:mods)
6467
nos MyCmd
@@ -72,29 +75,43 @@ function Test_cmdmods()
7275
call assert_equal('silent', g:mods)
7376
sil MyCmd
7477
call assert_equal('silent', g:mods)
78+
silent! MyCmd
79+
call assert_equal('silent!', g:mods)
80+
sil! MyCmd
81+
call assert_equal('silent!', g:mods)
7582
tab MyCmd
7683
call assert_equal('tab', g:mods)
7784
topleft MyCmd
7885
call assert_equal('topleft', g:mods)
7986
to MyCmd
8087
call assert_equal('topleft', g:mods)
81-
" unsilent MyCmd
88+
unsilent MyCmd
89+
call assert_equal('unsilent', g:mods)
90+
uns MyCmd
91+
call assert_equal('unsilent', g:mods)
8292
verbose MyCmd
8393
call assert_equal('verbose', g:mods)
8494
verb MyCmd
8595
call assert_equal('verbose', g:mods)
96+
0verbose MyCmd
97+
call assert_equal('0verbose', g:mods)
98+
3verbose MyCmd
99+
call assert_equal('3verbose', g:mods)
100+
999verbose MyCmd
101+
call assert_equal('999verbose', g:mods)
86102
vertical MyCmd
87103
call assert_equal('vertical', g:mods)
88104
vert MyCmd
89105
call assert_equal('vertical', g:mods)
90106

91107
aboveleft belowright botright browse confirm hide keepalt keepjumps
92-
\ keepmarks keeppatterns lockmarks noswapfile silent tab
93-
\ topleft verbose vertical MyCmd
108+
\ keepmarks keeppatterns lockmarks noautocmd noswapfile silent
109+
\ tab topleft unsilent verbose vertical MyCmd
94110

95111
call assert_equal('browse confirm hide keepalt keepjumps ' .
96-
\ 'keepmarks keeppatterns lockmarks noswapfile silent ' .
97-
\ 'verbose aboveleft belowright botright tab topleft vertical', g:mods)
112+
\ 'keepmarks keeppatterns lockmarks noswapfile unsilent noautocmd ' .
113+
\ 'silent verbose aboveleft belowright botright tab topleft vertical',
114+
\ g:mods)
98115

99116
let g:mods = ''
100117
command! -nargs=* MyQCmd let g:mods .= '<q-mods> '

src/usercmd.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1492,10 +1492,23 @@ produce_cmdmods(char_u *buf, cmdmod_T *cmod, int quote)
14921492
(cmod->cmod_flags & CMOD_ERRSILENT) ? "silent!"
14931493
: "silent", &multi_mods);
14941494
// :verbose
1495-
if (p_verbose > 0)
1496-
result += add_cmd_modifier(buf, "verbose", &multi_mods);
1495+
if (cmod->cmod_verbose > 0)
1496+
{
1497+
int verbose_value = cmod->cmod_verbose - 1;
1498+
1499+
if (verbose_value == 1)
1500+
result += add_cmd_modifier(buf, "verbose", &multi_mods);
1501+
else
1502+
{
1503+
char verbose_buf[NUMBUFLEN];
1504+
1505+
sprintf(verbose_buf, "%dverbose", verbose_value);
1506+
result += add_cmd_modifier(buf, verbose_buf, &multi_mods);
1507+
}
1508+
}
14971509
// flags from cmod->cmod_split
14981510
result += add_win_cmd_modifers(buf, cmod, &multi_mods);
1511+
14991512
if (quote && buf != NULL)
15001513
{
15011514
buf += result - 2;

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -735,6 +735,8 @@ static char *(features[]) =
735735

736736
static int included_patches[] =
737737
{ /* Add new patch number below this line */
738+
/**/
739+
31,
738740
/**/
739741
30,
740742
/**/

0 commit comments

Comments
 (0)