diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-08-13 12:25:01 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-13 12:25:01 +0800 |
commit | 1de62b9ea17b08db0fe37caf1f054b7b809120c3 (patch) | |
tree | 105f42dd76f70722032b9e343dd2226459ac84ae /src | |
parent | 754892e59dc3ab65a92d22f315e88b716bc26d1d (diff) | |
download | rneovim-1de62b9ea17b08db0fe37caf1f054b7b809120c3.tar.gz rneovim-1de62b9ea17b08db0fe37caf1f054b7b809120c3.tar.bz2 rneovim-1de62b9ea17b08db0fe37caf1f054b7b809120c3.zip |
fix(charclass): make behavior with empty str match latest Vim (#19749)
Later Vim patches changed to return 0 for empty string and null string.
Also update setcellwidth() docs to match latest Vim.
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/mbyte.c | 6 | ||||
-rw-r--r-- | src/nvim/testdir/test_functions.vim | 2 |
2 files changed, 4 insertions, 4 deletions
diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c index 378a08131d..53bbaab694 100644 --- a/src/nvim/mbyte.c +++ b/src/nvim/mbyte.c @@ -2861,10 +2861,8 @@ void f_setcellwidths(typval_T *argvars, typval_T *rettv, FunPtr fptr) void f_charclass(typval_T *argvars, typval_T *rettv, FunPtr fptr) { - if (argvars[0].v_type != VAR_STRING - || argvars[0].vval.v_string == NULL - || *argvars[0].vval.v_string == NUL) { - emsg(_(e_stringreq)); + if (tv_check_for_string(&argvars[0]) == FAIL + || argvars[0].vval.v_string == NULL) { return; } rettv->vval.v_number = mb_get_class((const char_u *)argvars[0].vval.v_string); diff --git a/src/nvim/testdir/test_functions.vim b/src/nvim/testdir/test_functions.vim index e0e0c1ca38..44b6f0373e 100644 --- a/src/nvim/testdir/test_functions.vim +++ b/src/nvim/testdir/test_functions.vim @@ -1774,6 +1774,8 @@ func Test_charclass() call assert_equal(1, charclass('.')) call assert_equal(2, charclass('x')) call assert_equal(3, charclass("\u203c")) + " this used to crash vim + call assert_equal(0, "xxx"[-1]->charclass()) endfunc func Test_eventhandler() |