0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

patch 9.0.1460: insufficient testing for getcmdcompltype()

Problem:    Insufficient testing for getcmdcompltype().
Solution:   Add a few more test cases. (closes #12268)
This commit is contained in:
zeertzjq
2023-04-17 15:53:24 +01:00
committed by Bram Moolenaar
parent e7d49465a4
commit 961b2e54bd
3 changed files with 19 additions and 10 deletions

View File

@@ -4152,11 +4152,11 @@ get_cmdline_completion(void)
if (p == NULL || p->xpc == NULL) if (p == NULL || p->xpc == NULL)
return NULL; return NULL;
char_u *cmd_compl;
set_expand_context(p->xpc); set_expand_context(p->xpc);
if (p->xpc->xp_context == EXPAND_UNSUCCESSFUL)
return NULL;
cmd_compl = cmdcomplete_type_to_str(p->xpc->xp_context); char_u *cmd_compl = cmdcomplete_type_to_str(p->xpc->xp_context);
if (cmd_compl != NULL) if (cmd_compl != NULL)
return vim_strsave(cmd_compl); return vim_strsave(cmd_compl);

View File

@@ -3337,16 +3337,23 @@ func Test_cmdline_complete_bang_cmd_argument()
call assert_equal('"!vim test_cmdline.vim', @:) call assert_equal('"!vim test_cmdline.vim', @:)
endfunc endfunc
func Check_completion() func Call_cmd_funcs()
call assert_equal('let a', getcmdline()) return string([getcmdpos(), getcmdscreenpos(), getcmdcompltype()])
call assert_equal(6, getcmdpos())
call assert_equal(7, getcmdscreenpos())
call assert_equal('var', getcmdcompltype())
return ''
endfunc endfunc
func Test_screenpos_and_completion() func Test_screenpos_and_completion()
call feedkeys(":let a\<C-R>=Check_completion()\<CR>\<Esc>", "xt") call assert_equal(0, getcmdpos())
call assert_equal(0, getcmdscreenpos())
call assert_equal('', getcmdcompltype())
cnoremap <expr> <F2> string([getcmdpos(), getcmdscreenpos(), getcmdcompltype()])
call feedkeys(":let a\<F2>\<C-B>\"\<CR>", "xt")
call assert_equal("\"let a[6, 7, 'var']", @:)
call feedkeys(":quit \<F2>\<C-B>\"\<CR>", "xt")
call assert_equal("\"quit [6, 7, '']", @:)
call feedkeys(":nosuchcommand \<F2>\<C-B>\"\<CR>", "xt")
call assert_equal("\"nosuchcommand [15, 16, '']", @:)
cunmap <F2>
endfunc endfunc
func Test_recursive_register() func Test_recursive_register()

View File

@@ -695,6 +695,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
1460,
/**/ /**/
1459, 1459,
/**/ /**/