summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-08-17 23:48:58 +0200
committerChristian Brabandt <cb@256bit.org>2023-08-17 23:48:58 +0200
commitbe5cdd1d634c2dfc7e415499fb18f4d246a8721c (patch)
tree954b0530cecaf7040891d51dedf41988ab03b26c
parentd2af6c66fe9b6bbb58d6ffdf8b3aa6e57d993b1f (diff)
patch 9.0.1734: :runtime completion fails for multiple argsv9.0.1734
Problem: :runtime completion fails for multiple args Solution: Make it work closes: #12616 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: zeertzjq <zeertzjq@outlook.com>
-rw-r--r--src/scriptfile.c9
-rw-r--r--src/testdir/test_packadd.vim35
-rw-r--r--src/version.c2
3 files changed, 44 insertions, 2 deletions
diff --git a/src/scriptfile.c b/src/scriptfile.c
index 37d57e51e9..2aca346d0f 100644
--- a/src/scriptfile.c
+++ b/src/scriptfile.c
@@ -289,6 +289,15 @@ set_context_in_runtime_cmd(expand_T *xp, char_u *arg)
char_u *p = skiptowhite(arg);
runtime_expand_flags
= *p != NUL ? get_runtime_cmd_flags(&arg, p - arg) : 0;
+ // Skip to the last argument.
+ while (*(p = skiptowhite_esc(arg)) != NUL)
+ {
+ if (runtime_expand_flags == 0)
+ // When there are multiple arguments and [where] is not specified,
+ // use an unrelated non-zero flag to avoid expanding [where].
+ runtime_expand_flags = DIP_ALL;
+ arg = skipwhite(p);
+ }
xp->xp_context = EXPAND_RUNTIME;
xp->xp_pattern = arg;
}
diff --git a/src/testdir/test_packadd.vim b/src/testdir/test_packadd.vim
index 33dcfe0f20..eab710def4 100644
--- a/src/testdir/test_packadd.vim
+++ b/src/testdir/test_packadd.vim
@@ -433,9 +433,9 @@ func Test_runtime_completion()
call writefile([], optdir . '/../Aunrelated')
exe 'set rtp=' . &packpath . '/runtime'
- func Check_runtime_completion(arg, arg1, res)
+ func Check_runtime_completion(arg, arg_prev, res)
call feedkeys(':runtime ' .. a:arg .. "\<C-A>\<C-B>\"\<CR>", 'xt')
- call assert_equal('"runtime ' .. a:arg1 .. join(a:res), @:)
+ call assert_equal('"runtime ' .. a:arg_prev .. join(a:res), @:)
call assert_equal(a:res, getcompletion(a:arg, 'runtime'))
endfunc
@@ -449,39 +449,70 @@ func Test_runtime_completion()
\ ['PACK'])
call Check_runtime_completion('A', '',
\ ['Aextra/', 'Arunfoo.vim', 'ALL'])
+ call Check_runtime_completion('Other.vim ', 'Other.vim ',
+ \ ['Aextra/', 'Arunfoo.vim'])
call Check_runtime_completion('Aextra/', '',
\ ['Aextra/Arunbar.vim', 'Aextra/Arunbaz/'])
+ call Check_runtime_completion('Other.vim Aextra/', 'Other.vim ',
+ \ ['Aextra/Arunbar.vim', 'Aextra/Arunbaz/'])
call Check_runtime_completion('START ', 'START ',
\ ['Aextra/', 'Astartfoo.vim'])
+ call Check_runtime_completion('START Other.vim ', 'START Other.vim ',
+ \ ['Aextra/', 'Astartfoo.vim'])
call Check_runtime_completion('START A', 'START ',
\ ['Aextra/', 'Astartfoo.vim'])
+ call Check_runtime_completion('START Other.vim A', 'START Other.vim ',
+ \ ['Aextra/', 'Astartfoo.vim'])
call Check_runtime_completion('START Aextra/', 'START ',
\ ['Aextra/Astartbar.vim', 'Aextra/Astartbaz/'])
+ call Check_runtime_completion('START Other.vim Aextra/', 'START Other.vim ',
+ \ ['Aextra/Astartbar.vim', 'Aextra/Astartbaz/'])
call Check_runtime_completion('OPT ', 'OPT ',
\ ['Aextra/', 'Aoptfoo.vim'])
+ call Check_runtime_completion('OPT Other.vim ', 'OPT Other.vim ',
+ \ ['Aextra/', 'Aoptfoo.vim'])
call Check_runtime_completion('OPT A', 'OPT ',
\ ['Aextra/', 'Aoptfoo.vim'])
+ call Check_runtime_completion('OPT Other.vim A', 'OPT Other.vim ',
+ \ ['Aextra/', 'Aoptfoo.vim'])
call Check_runtime_completion('OPT Aextra/', 'OPT ',
\ ['Aextra/Aoptbar.vim', 'Aextra/Aoptbaz/'])
+ call Check_runtime_completion('OPT Other.vim Aextra/', 'OPT Other.vim ',
+ \ ['Aextra/Aoptbar.vim', 'Aextra/Aoptbaz/'])
call Check_runtime_completion('PACK ', 'PACK ',
\ ['Aextra/', 'Aoptfoo.vim', 'Astartfoo.vim'])
+ call Check_runtime_completion('PACK Other.vim ', 'PACK Other.vim ',
+ \ ['Aextra/', 'Aoptfoo.vim', 'Astartfoo.vim'])
call Check_runtime_completion('PACK A', 'PACK ',
\ ['Aextra/', 'Aoptfoo.vim', 'Astartfoo.vim'])
+ call Check_runtime_completion('PACK Other.vim A', 'PACK Other.vim ',
+ \ ['Aextra/', 'Aoptfoo.vim', 'Astartfoo.vim'])
call Check_runtime_completion('PACK Aextra/', 'PACK ',
\ ['Aextra/Aoptbar.vim', 'Aextra/Aoptbaz/',
\ 'Aextra/Astartbar.vim', 'Aextra/Astartbaz/'])
+ call Check_runtime_completion('PACK Other.vim Aextra/', 'PACK Other.vim ',
+ \ ['Aextra/Aoptbar.vim', 'Aextra/Aoptbaz/',
+ \ 'Aextra/Astartbar.vim', 'Aextra/Astartbaz/'])
call Check_runtime_completion('ALL ', 'ALL ',
\ ['Aextra/', 'Aoptfoo.vim', 'Arunfoo.vim', 'Astartfoo.vim'])
+ call Check_runtime_completion('ALL Other.vim ', 'ALL Other.vim ',
+ \ ['Aextra/', 'Aoptfoo.vim', 'Arunfoo.vim', 'Astartfoo.vim'])
call Check_runtime_completion('ALL A', 'ALL ',
\ ['Aextra/', 'Aoptfoo.vim', 'Arunfoo.vim', 'Astartfoo.vim'])
+ call Check_runtime_completion('ALL Other.vim A', 'ALL Other.vim ',
+ \ ['Aextra/', 'Aoptfoo.vim', 'Arunfoo.vim', 'Astartfoo.vim'])
call Check_runtime_completion('ALL Aextra/', 'ALL ',
\ ['Aextra/Aoptbar.vim', 'Aextra/Aoptbaz/',
\ 'Aextra/Arunbar.vim', 'Aextra/Arunbaz/',
\ 'Aextra/Astartbar.vim', 'Aextra/Astartbaz/'])
+ call Check_runtime_completion('ALL Other.vim Aextra/', 'ALL Other.vim ',
+ \ ['Aextra/Aoptbar.vim', 'Aextra/Aoptbaz/',
+ \ 'Aextra/Arunbar.vim', 'Aextra/Arunbaz/',
+ \ 'Aextra/Astartbar.vim', 'Aextra/Astartbaz/'])
delfunc Check_runtime_completion
endfunc
diff --git a/src/version.c b/src/version.c
index 539b3899ab..ba423184d4 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 */
/**/
+ 1734,
+/**/
1733,
/**/
1732,