summaryrefslogtreecommitdiff
path: root/src/usercmd.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-07-22 21:55:18 +0200
committerBram Moolenaar <Bram@vim.org>2019-07-22 21:55:18 +0200
commitf03e328348f87e1fe8ce4aad2a6a4237b9f78ce3 (patch)
tree4b02e96a3b759a0b2560fea8ae81141c87a92176 /src/usercmd.c
parent26b654a5df9414e43734eb4c956b67c331d70a50 (diff)
downloadvim-git-f03e328348f87e1fe8ce4aad2a6a4237b9f78ce3.tar.gz
patch 8.1.1732: completion in cmdwin does not work for buffer-local commandsv8.1.1732
Problem: Completion in cmdwin does not work for buffer-local commands. Solution: Use the right buffer. (closes #4711)
Diffstat (limited to 'src/usercmd.c')
-rw-r--r--src/usercmd.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/src/usercmd.c b/src/usercmd.c
index 9e09a8b3c..c04c80e23 100644
--- a/src/usercmd.c
+++ b/src/usercmd.c
@@ -309,9 +309,16 @@ get_user_command_name(int idx)
char_u *
get_user_commands(expand_T *xp UNUSED, int idx)
{
- if (idx < curbuf->b_ucmds.ga_len)
- return USER_CMD_GA(&curbuf->b_ucmds, idx)->uc_name;
- idx -= curbuf->b_ucmds.ga_len;
+ // In cmdwin, the alternative buffer should be used.
+ buf_T *buf =
+#ifdef FEAT_CMDWIN
+ (cmdwin_type != 0 && get_cmdline_type() == NUL) ? prevwin->w_buffer :
+#endif
+ curbuf;
+
+ if (idx < buf->b_ucmds.ga_len)
+ return USER_CMD_GA(&buf->b_ucmds, idx)->uc_name;
+ idx -= buf->b_ucmds.ga_len;
if (idx < ucmds.ga_len)
return USER_CMD(idx)->uc_name;
return NULL;
@@ -395,7 +402,13 @@ uc_list(char_u *name, size_t name_len)
long a;
garray_T *gap;
- gap = &curbuf->b_ucmds;
+ /* In cmdwin, the alternative buffer should be used. */
+ gap =
+#ifdef FEAT_CMDWIN
+ (cmdwin_type != 0 && get_cmdline_type() == NUL) ?
+ &prevwin->w_buffer->b_ucmds :
+#endif
+ &curbuf->b_ucmds;
for (;;)
{
for (i = 0; i < gap->ga_len; ++i)