Patch 9.0.0437

4 views
Skip to first unread message

Bram Moolenaar

unread,
Sep 10, 2022, 8:53:17 AM9/10/22
to vim...@googlegroups.com

Patch 9.0.0437
Problem: No error when a custom completion function returns something else
than the expected list.
Solution: Give an error. (closes #11100)
Files: src/eval.c, src/errors.h, src/testdir/test_usercommands.vim


*** ../vim-9.0.0436/src/eval.c 2022-09-10 12:35:56.983208759 +0100
--- src/eval.c 2022-09-10 13:33:54.150824778 +0100
***************
*** 842,847 ****
--- 842,848 ----
* Call Vim script function "func" and return the result as a List.
* Uses "argv" and "argc" as call_func_retstr().
* Returns NULL when there is something wrong.
+ * Gives an error when the returned value is not a list.
*/
void *
call_func_retlist(
***************
*** 856,861 ****
--- 857,864 ----

if (rettv.v_type != VAR_LIST)
{
+ semsg(_(e_custom_list_completion_function_does_not_return_list_but_str),
+ vartype_name(rettv.v_type));
clear_tv(&rettv);
return NULL;
}
*** ../vim-9.0.0436/src/errors.h 2022-09-10 13:03:08.959148178 +0100
--- src/errors.h 2022-09-10 13:39:58.826858879 +0100
***************
*** 3333,3336 ****
--- 3333,3338 ----
INIT(= N_("E1301: String, Number, List or Blob required for argument %d"));
EXTERN char e_script_variable_was_deleted[]
INIT(= N_("E1302: Script variable was deleted"));
+ EXTERN char e_custom_list_completion_function_does_not_return_list_but_str[]
+ INIT(= N_("E1303: Custom list completion function does not return a List but a %s"));
#endif
*** ../vim-9.0.0436/src/testdir/test_usercommands.vim 2022-09-01 12:58:46.584970141 +0100
--- src/testdir/test_usercommands.vim 2022-09-10 13:50:20.222058104 +0100
***************
*** 666,672 ****
return "a\nb\n"
endfunc
command -nargs=* -complete=customlist,T1 TCmd1
! call feedkeys(":TCmd1 \<C-A>\<C-B>\"\<CR>", 'xt')
call assert_equal('"TCmd1 ', @:)
delcommand TCmd1
delfunc T1
--- 666,672 ----
return "a\nb\n"
endfunc
command -nargs=* -complete=customlist,T1 TCmd1
! call assert_fails('call feedkeys(":TCmd1 \<C-A>\<C-B>\"\<CR>", "xt")', 'E1303: Custom list completion function does not return a List but a string')
call assert_equal('"TCmd1 ', @:)
delcommand TCmd1
delfunc T1
***************
*** 675,681 ****
return {}
endfunc
command -nargs=* -complete=customlist,T2 TCmd2
! call feedkeys(":TCmd2 \<C-A>\<C-B>\"\<CR>", 'xt')
call assert_equal('"TCmd2 ', @:)
delcommand TCmd2
delfunc T2
--- 675,681 ----
return {}
endfunc
command -nargs=* -complete=customlist,T2 TCmd2
! call assert_fails('call feedkeys(":TCmd2 \<C-A>\<C-B>\"\<CR>", "xt")', 'E1303: Custom list completion function does not return a List but a dict')
call assert_equal('"TCmd2 ', @:)
delcommand TCmd2
delfunc T2
*** ../vim-9.0.0436/src/version.c 2022-09-10 13:03:08.959148178 +0100
--- src/version.c 2022-09-10 13:26:38.671563628 +0100
***************
*** 705,706 ****
--- 705,708 ----
{ /* Add new patch number below this line */
+ /**/
+ 437,
/**/

--
On the other hand, you have different fingers.
-- Steven Wright

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages