patch 9.1.1351: Return value of getcmdline() inconsistent in CmdlineLeavePre
Problem: Return value of getcmdline() inconsistent in CmdlineLeavePre
when leaving cmdline in different ways (after v9.1.1329).
Solution: Trigger CmdlineLeavePre before calling abandon_cmdline() so
that getcmdline() can return the command line (zeertzjq).
closes: #17218
Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Girish Palya <girishji@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
committed by
Christian Brabandt
parent
6220bbad4e
commit
9240369774
@ -2560,6 +2560,9 @@ cmdline_changed:
|
|||||||
}
|
}
|
||||||
|
|
||||||
returncmd:
|
returncmd:
|
||||||
|
// Trigger CmdlineLeavePre autocommands if not already triggered.
|
||||||
|
if (!event_cmdlineleavepre_triggered)
|
||||||
|
trigger_cmd_autocmd(cmdline_type, EVENT_CMDLINELEAVEPRE);
|
||||||
|
|
||||||
#ifdef FEAT_RIGHTLEFT
|
#ifdef FEAT_RIGHTLEFT
|
||||||
cmdmsg_rl = FALSE;
|
cmdmsg_rl = FALSE;
|
||||||
@ -2616,10 +2619,6 @@ returncmd:
|
|||||||
if (some_key_typed)
|
if (some_key_typed)
|
||||||
need_wait_return = FALSE;
|
need_wait_return = FALSE;
|
||||||
|
|
||||||
// Trigger CmdlineLeavePre autocommands if not already triggered.
|
|
||||||
if (!event_cmdlineleavepre_triggered)
|
|
||||||
trigger_cmd_autocmd(cmdline_type, EVENT_CMDLINELEAVEPRE);
|
|
||||||
|
|
||||||
// Trigger CmdlineLeave autocommands.
|
// Trigger CmdlineLeave autocommands.
|
||||||
trigger_cmd_autocmd(cmdline_type, EVENT_CMDLINELEAVE);
|
trigger_cmd_autocmd(cmdline_type, EVENT_CMDLINELEAVE);
|
||||||
|
|
||||||
|
|||||||
@ -2066,11 +2066,28 @@ func Test_Cmdline_Trigger()
|
|||||||
call assert_equal('CmdlineLeavePre', g:log)
|
call assert_equal('CmdlineLeavePre', g:log)
|
||||||
call assert_equal('CmdlineLeave', g:log2)
|
call assert_equal('CmdlineLeave', g:log2)
|
||||||
|
|
||||||
let g:count = 0
|
autocmd CmdlineLeavePre * let g:cmdline += [getcmdline()]
|
||||||
autocmd CmdlineLeavePre * let g:count += 1
|
|
||||||
call feedkeys(":let c = input('? ')\<cr>B\<cr>", "tx")
|
for end_keys in ["\<CR>", "\<NL>", "\<kEnter>", "\<C-C>", "\<Esc>",
|
||||||
call assert_equal(2, g:count)
|
\ "\<C-\>\<C-N>", "\<C-\>\<C-G>"]
|
||||||
unlet! g:count
|
let g:cmdline = []
|
||||||
|
let g:log = ''
|
||||||
|
let g:log2 = ''
|
||||||
|
call assert_equal('', g:log)
|
||||||
|
let keys = $':echo "hello"{end_keys}'
|
||||||
|
let msg = keytrans(keys)
|
||||||
|
call feedkeys(keys, "tx")
|
||||||
|
call assert_equal(['echo "hello"'], g:cmdline, msg)
|
||||||
|
call assert_equal('CmdlineLeavePre', g:log, msg)
|
||||||
|
call assert_equal('CmdlineLeave', g:log2, msg)
|
||||||
|
endfor
|
||||||
|
|
||||||
|
let g:cmdline = []
|
||||||
|
call feedkeys(":let c = input('? ')\<cr>ABCDE\<cr>", "tx")
|
||||||
|
call assert_equal(["let c = input('? ')", 'ABCDE'], g:cmdline)
|
||||||
|
|
||||||
|
au! CmdlineLeavePre
|
||||||
|
unlet! g:cmdline
|
||||||
unlet! g:log
|
unlet! g:log
|
||||||
unlet! g:log2
|
unlet! g:log2
|
||||||
bw!
|
bw!
|
||||||
|
|||||||
@ -704,6 +704,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1351,
|
||||||
/**/
|
/**/
|
||||||
1350,
|
1350,
|
||||||
/**/
|
/**/
|
||||||
|
|||||||
Reference in New Issue
Block a user