neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit e25193143bca3a48920322634120a442854bb891
parent 562d572926e0c11329c13c9df45be7170888e7f6
Author: zeertzjq <zeertzjq@outlook.com>
Date:   Sat,  5 Nov 2022 14:59:45 +0800

vim-patch:8.2.1751: using 2 where bool is expected may throw an error

Problem:    Using 2 where bool is expected may throw an error.
Solution:   Make this backwards compatible.

https://github.com/vim/vim/commit/bade44e5cad1b08c85d4a8ba08d94a30458dddfb

In legacy Vim script get_bool functions do the same thing as get_number
functions, so just add aliases using #define.

N/A patches for version.c:

vim-patch:8.2.1506: Vim9: no error when using a number other than 0 or 1 as bool

Problem:    Vim9: no error when using a number other than 0 or 1 as bool.
Solution:   Check the number is 0 or 1.

https://github.com/vim/vim/commit/d70840ed68296c1144d743e6335003c81c558c24

Co-authored-by: Bram Moolenaar <Bram@vim.org>

Diffstat:
Msrc/nvim/eval/funcs.c | 6++++--
Msrc/nvim/eval/typval.h | 5+++++
Msrc/nvim/testdir/test_search.vim | 3+++
3 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c @@ -112,6 +112,8 @@ PRAGMA_DIAG_POP static char *e_listblobarg = N_("E899: Argument of %s must be a List or Blob"); static char *e_invalwindow = N_("E957: Invalid window number"); static char *e_reduceempty = N_("E998: Reduce of an empty %s with no initial value"); +static char e_using_number_as_bool_nr[] + = N_("E1023: Using a Number as a Bool: %d"); static char e_cannot_resize_window_in_another_tab_page[] = N_("E1308: Cannot resize a window in another tab page"); @@ -1361,7 +1363,7 @@ static void f_deepcopy(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) noref = (int)tv_get_number_chk(&argvars[1], NULL); } if (noref < 0 || noref > 1) { - emsg(_(e_invarg)); + semsg(_(e_using_number_as_bool_nr), noref); } else { var_item_copy(NULL, &argvars[0], rettv, true, (noref == 0 ? get_copyID() @@ -8457,7 +8459,7 @@ static void f_strchars(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) skipcc = (int)tv_get_number_chk(&argvars[1], NULL); } if (skipcc < 0 || skipcc > 1) { - emsg(_(e_invarg)); + semsg(_(e_using_number_as_bool_nr), skipcc); } else { func_mb_ptr2char_adv = skipcc ? mb_ptr2char_adv : mb_cptr2char_adv; while (*s != NUL) { diff --git a/src/nvim/eval/typval.h b/src/nvim/eval/typval.h @@ -559,4 +559,9 @@ EXTERN const size_t kTVTranslate INIT(= TV_TRANSLATE); #ifdef INCLUDE_GENERATED_DECLARATIONS # include "eval/typval.h.generated.h" #endif + +#define tv_get_bool tv_get_number +#define tv_get_bool_chk tv_get_number_chk +#define tv_dict_get_bool tv_dict_get_number_def + #endif // NVIM_EVAL_TYPVAL_H diff --git a/src/nvim/testdir/test_search.vim b/src/nvim/testdir/test_search.vim @@ -294,6 +294,9 @@ func Test_searchpair() new call setline(1, ['other code', 'here [', ' [', ' " cursor here', ' ]]']) + " should not give an error for using "42" + call assert_equal(0, searchpair('a', 'b', 'c', '', 42)) + 4 call assert_equal(3, searchpair('\[', '', ']', 'bW')) call assert_equal([0, 3, 2, 0], getpos('.'))