comparison src/usercmd.c @ 17468:fa6c9047ec70 v8.1.1732

patch 8.1.1732: completion in cmdwin does not work for buffer-local commands commit https://github.com/vim/vim/commit/f03e328348f87e1fe8ce4aad2a6a4237b9f78ce3 Author: Bram Moolenaar <Bram@vim.org> Date: Mon Jul 22 21:55:18 2019 +0200 patch 8.1.1732: completion in cmdwin does not work for buffer-local commands Problem: Completion in cmdwin does not work for buffer-local commands. Solution: Use the right buffer. (closes https://github.com/vim/vim/issues/4711)
author Bram Moolenaar <Bram@vim.org>
date Mon, 22 Jul 2019 22:00:05 +0200
parents 81705f4d9e03
children 9efb4dda9720
comparison
equal deleted inserted replaced
17467:ed03a1fb37ce 17468:fa6c9047ec70
307 * Function given to ExpandGeneric() to obtain the list of user command names. 307 * Function given to ExpandGeneric() to obtain the list of user command names.
308 */ 308 */
309 char_u * 309 char_u *
310 get_user_commands(expand_T *xp UNUSED, int idx) 310 get_user_commands(expand_T *xp UNUSED, int idx)
311 { 311 {
312 if (idx < curbuf->b_ucmds.ga_len) 312 // In cmdwin, the alternative buffer should be used.
313 return USER_CMD_GA(&curbuf->b_ucmds, idx)->uc_name; 313 buf_T *buf =
314 idx -= curbuf->b_ucmds.ga_len; 314 #ifdef FEAT_CMDWIN
315 (cmdwin_type != 0 && get_cmdline_type() == NUL) ? prevwin->w_buffer :
316 #endif
317 curbuf;
318
319 if (idx < buf->b_ucmds.ga_len)
320 return USER_CMD_GA(&buf->b_ucmds, idx)->uc_name;
321 idx -= buf->b_ucmds.ga_len;
315 if (idx < ucmds.ga_len) 322 if (idx < ucmds.ga_len)
316 return USER_CMD(idx)->uc_name; 323 return USER_CMD(idx)->uc_name;
317 return NULL; 324 return NULL;
318 } 325 }
319 326
393 int len; 400 int len;
394 int over; 401 int over;
395 long a; 402 long a;
396 garray_T *gap; 403 garray_T *gap;
397 404
398 gap = &curbuf->b_ucmds; 405 /* In cmdwin, the alternative buffer should be used. */
406 gap =
407 #ifdef FEAT_CMDWIN
408 (cmdwin_type != 0 && get_cmdline_type() == NUL) ?
409 &prevwin->w_buffer->b_ucmds :
410 #endif
411 &curbuf->b_ucmds;
399 for (;;) 412 for (;;)
400 { 413 {
401 for (i = 0; i < gap->ga_len; ++i) 414 for (i = 0; i < gap->ga_len; ++i)
402 { 415 {
403 cmd = USER_CMD_GA(gap, i); 416 cmd = USER_CMD_GA(gap, i);