Patch 9.0.0081
Problem: Command line completion of user command may have duplicates.
(Dani Dickstein)
Solution: Skip global user command if an identical buffer-local one is
defined. (closes #10797)
Files: src/usercmd.c, src/testdir/test_cmdline.vim
*** ../vim-9.0.0080/src/usercmd.c 2022-07-03 13:15:57.988497914 +0100
--- src/usercmd.c 2022-07-26 17:22:37.186218546 +0100
***************
*** 363,371 ****
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;
}
--- 363,381 ----
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)
! {
! int i;
! char_u *name = USER_CMD(idx)->uc_name;
!
! for (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 (char_u *)"";
! return name;
! }
return NULL;
}
*** ../vim-9.0.0080/src/testdir/test_cmdline.vim 2022-07-02
16:29:15.027193547 +0100
--- src/testdir/test_cmdline.vim 2022-07-26 17:22:22.318278732 +0100
***************
*** 842,847 ****
--- 842,857 ----
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
*** ../vim-9.0.0080/src/version.c 2022-07-26 16:03:35.182058189 +0100
--- src/version.c 2022-07-26 17:23:27.226016399 +0100
***************
*** 737,738 ****
--- 737,740 ----
{ /* Add new patch number below this line */
+ /**/
+ 81,
/**/
--
hundred-and-one symptoms of being an internet addict:
136. You decide to stay in a low-paying job teaching just for the
free Internet access.
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/20220726162451.CC7561C07D3%40moolenaar.net.