# HG changeset patch # User Bram Moolenaar # Date 1681743605 -7200 # Node ID 6ababf71c1b1b95e504aa4d3e941f5a0520bf145 # Parent e961acb64f50b6d3fbfa24ab05bd27f46b9589f5 patch 9.0.1460: insufficient testing for getcmdcompltype() Commit: https://github.com/vim/vim/commit/961b2e54bdbe1c06e4bf8ccf7a7e3deb129b45de Author: zeertzjq Date: Mon Apr 17 15:53:24 2023 +0100 patch 9.0.1460: insufficient testing for getcmdcompltype() Problem: Insufficient testing for getcmdcompltype(). Solution: Add a few more test cases. (closes https://github.com/vim/vim/issues/12268) diff --git a/src/ex_getln.c b/src/ex_getln.c --- a/src/ex_getln.c +++ b/src/ex_getln.c @@ -4152,11 +4152,11 @@ get_cmdline_completion(void) if (p == NULL || p->xpc == NULL) return NULL; - char_u *cmd_compl; - set_expand_context(p->xpc); - - cmd_compl = cmdcomplete_type_to_str(p->xpc->xp_context); + if (p->xpc->xp_context == EXPAND_UNSUCCESSFUL) + return NULL; + + char_u *cmd_compl = cmdcomplete_type_to_str(p->xpc->xp_context); if (cmd_compl != NULL) return vim_strsave(cmd_compl); diff --git a/src/testdir/test_cmdline.vim b/src/testdir/test_cmdline.vim --- a/src/testdir/test_cmdline.vim +++ b/src/testdir/test_cmdline.vim @@ -3337,16 +3337,23 @@ func Test_cmdline_complete_bang_cmd_argu call assert_equal('"!vim test_cmdline.vim', @:) endfunc -func Check_completion() - call assert_equal('let a', getcmdline()) - call assert_equal(6, getcmdpos()) - call assert_equal(7, getcmdscreenpos()) - call assert_equal('var', getcmdcompltype()) - return '' +func Call_cmd_funcs() + return string([getcmdpos(), getcmdscreenpos(), getcmdcompltype()]) endfunc func Test_screenpos_and_completion() - call feedkeys(":let a\=Check_completion()\\", "xt") + call assert_equal(0, getcmdpos()) + call assert_equal(0, getcmdscreenpos()) + call assert_equal('', getcmdcompltype()) + + cnoremap string([getcmdpos(), getcmdscreenpos(), getcmdcompltype()]) + call feedkeys(":let a\\\"\", "xt") + call assert_equal("\"let a[6, 7, 'var']", @:) + call feedkeys(":quit \\\"\", "xt") + call assert_equal("\"quit [6, 7, '']", @:) + call feedkeys(":nosuchcommand \\\"\", "xt") + call assert_equal("\"nosuchcommand [15, 16, '']", @:) + cunmap endfunc func Test_recursive_register() diff --git a/src/version.c b/src/version.c --- 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 */ /**/ + 1460, +/**/ 1459, /**/ 1458,