diff options
author | Yegappan Lakshmanan <yegappan@yahoo.com> | 2023-06-08 17:09:45 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2023-06-08 17:09:45 +0100 |
commit | 577922b917e48285a7a312daf7b5bbc6e272939c (patch) | |
tree | f7cc5d7eb4c47da733a1fcf24a3393881889b7b2 /src/evalfunc.c | |
parent | 5bf042810b19a627eda2f170624a0cfd7b4f6ed6 (diff) |
patch 9.0.1617: charidx() result is not consistent with byteidx()v9.0.1617
Problem: charidx() and utf16idx() result is not consistent with byteidx().
Solution: When the index is equal to the length of the text return the
lenght of the text instead of -1. (Yegappan Lakshmanan,
closes #12503)
Diffstat (limited to 'src/evalfunc.c')
-rw-r--r-- | src/evalfunc.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/evalfunc.c b/src/evalfunc.c index 62e9a40624..63ca0486fe 100644 --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -1099,6 +1099,7 @@ static argcheck_T arg3_string_string_number[] = {arg_string, arg_string, arg_num static argcheck_T arg4_number_number_string_any[] = {arg_number, arg_number, arg_string, NULL}; static argcheck_T arg4_string_string_any_string[] = {arg_string, arg_string, NULL, arg_string}; static argcheck_T arg4_string_string_number_string[] = {arg_string, arg_string, arg_number, arg_string}; +static argcheck_T arg4_string_number_bool_bool[] = {arg_string, arg_number, arg_bool, arg_bool}; /* Function specific argument types (not covered by the above) */ static argcheck_T arg15_assert_fails[] = {arg_string_or_nr, arg_string_or_list_any, NULL, arg_number, arg_string}; static argcheck_T arg34_assert_inrange[] = {arg_float_or_nr, arg_float_or_nr, arg_float_or_nr, arg_string}; @@ -1814,7 +1815,7 @@ static funcentry_T global_functions[] = ret_number, f_charclass}, {"charcol", 1, 2, FEARG_1, arg2_string_or_list_number, ret_number, f_charcol}, - {"charidx", 2, 4, FEARG_1, arg3_string_number_bool, + {"charidx", 2, 4, FEARG_1, arg4_string_number_bool_bool, ret_number, f_charidx}, {"chdir", 1, 1, FEARG_1, arg1_string, ret_string, f_chdir}, @@ -2798,7 +2799,7 @@ static funcentry_T global_functions[] = ret_dict_any, f_undotree}, {"uniq", 1, 3, FEARG_1, arg13_sortuniq, ret_first_arg, f_uniq}, - {"utf16idx", 2, 4, FEARG_1, arg3_string_number_bool, + {"utf16idx", 2, 4, FEARG_1, arg4_string_number_bool_bool, ret_number, f_utf16idx}, {"values", 1, 1, FEARG_1, arg1_dict_any, ret_list_member, f_values}, @@ -3630,7 +3631,7 @@ f_copy(typval_T *argvars, typval_T *rettv) /* * Set the cursor position. - * If 'charcol' is TRUE, then use the column number as a character offset. + * If "charcol" is TRUE, then use the column number as a character offset. * Otherwise use the column number as a byte offset. */ static void |