summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-02-20 15:25:13 +0000
committerBram Moolenaar <Bram@vim.org>2023-02-20 15:25:13 +0000
commitb444ee761a2956a996a75d923281c51fa1a759f3 (patch)
treed69332aa7563f62546d2fca0112d121f73dc612e
parente1121b139480f53d1b06f84f3e4574048108fa0b (diff)
patch 9.0.1332: crash when using buffer-local user command in cmdline windowv9.0.1332
Problem: Crash when using buffer-local user command in cmdline window. (Karl Yngve LervÄg) Solution: Use the right buffer to find the user command. (closes #12030, closes #12029)
-rw-r--r--src/testdir/test_usercommands.vim9
-rw-r--r--src/usercmd.c2
-rw-r--r--src/version.c2
3 files changed, 12 insertions, 1 deletions
diff --git a/src/testdir/test_usercommands.vim b/src/testdir/test_usercommands.vim
index d8b4cb40e0..1e1856727a 100644
--- a/src/testdir/test_usercommands.vim
+++ b/src/testdir/test_usercommands.vim
@@ -856,6 +856,15 @@ func Test_buflocal_ambiguous_usercmd()
bw!
endfunc
+" Test for using buffer-local user command from cmdwin.
+func Test_buflocal_usercmd_cmdwin()
+ new
+ command -buffer TestCmd edit Test
+ " This used to crash Vim
+ call assert_fails("norm q::TestCmd\<CR>", 'E11:')
+ bw!
+endfunc
+
" Test for using a multibyte character in a user command
func Test_multibyte_in_usercmd()
command SubJapanesePeriodToDot exe "%s/\u3002/./g"
diff --git a/src/usercmd.c b/src/usercmd.c
index 44fa578f69..7d844620bd 100644
--- a/src/usercmd.c
+++ b/src/usercmd.c
@@ -1838,7 +1838,7 @@ do_ucmd(exarg_T *eap)
if (eap->cmdidx == CMD_USER)
cmd = USER_CMD(eap->useridx);
else
- cmd = USER_CMD_GA(&curbuf->b_ucmds, eap->useridx);
+ cmd = USER_CMD_GA(&prevwin_curwin()->w_buffer->b_ucmds, eap->useridx);
/*
* Replace <> in the command by the arguments.
diff --git a/src/version.c b/src/version.c
index 4c12823275..0095489c7e 100644
--- a/src/version.c
+++ b/src/version.c
@@ -696,6 +696,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1332,
+/**/
1331,
/**/
1330,