aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/nvim/ex_docmd.c11
-rw-r--r--src/nvim/testdir/test_cmdline.vim10
2 files changed, 20 insertions, 1 deletions
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index 0a9285b7fe..6963ede3ae 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -6788,9 +6788,18 @@ char *get_user_commands(expand_T *xp FUNC_ATTR_UNUSED, int idx)
if (idx < buf->b_ucmds.ga_len) {
return (char *)USER_CMD_GA(&buf->b_ucmds, idx)->uc_name;
}
+
idx -= buf->b_ucmds.ga_len;
if (idx < ucmds.ga_len) {
- return (char *)USER_CMD(idx)->uc_name;
+ char *name = (char *)USER_CMD(idx)->uc_name;
+
+ for (int i = 0; i < buf->b_ucmds.ga_len; i++) {
+ if (STRCMP(name, USER_CMD_GA(&buf->b_ucmds, i)->uc_name) == 0) {
+ // global command is overruled by buffer-local one
+ return "";
+ }
+ }
+ return name;
}
return NULL;
}
diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim
index a0907d79ac..094c6fd8d4 100644
--- a/src/nvim/testdir/test_cmdline.vim
+++ b/src/nvim/testdir/test_cmdline.vim
@@ -704,6 +704,16 @@ func Test_cmdline_complete_user_cmd()
delcommand Foo
endfunc
+func Test_complete_user_cmd()
+ command FooBar echo 'global'
+ command -buffer FooBar echo 'local'
+ call feedkeys(":Foo\<C-A>\<Home>\"\<CR>", 'tx')
+ call assert_equal('"FooBar', @:)
+
+ delcommand -buffer FooBar
+ delcommand FooBar
+endfunc
+
func s:ScriptLocalFunction()
echo 'yes'
endfunc