aboutsummaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-06-09 17:43:46 +0800
committerGitHub <noreply@github.com>2023-06-09 17:43:46 +0800
commit106922898ad1510954737d38e7f8db78559ae6bd (patch)
tree05c95cb03be4dbfa9b9bc21bc20fe13c85885ccb /runtime
parente5e0bda41b640d324350c5147b956e37e9f8b32c (diff)
downloadrneovim-106922898ad1510954737d38e7f8db78559ae6bd.tar.gz
rneovim-106922898ad1510954737d38e7f8db78559ae6bd.tar.bz2
rneovim-106922898ad1510954737d38e7f8db78559ae6bd.zip
vim-patch:9.0.1617: charidx() result is not consistent with byteidx() (#23963)
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 vim/vim#12503) https://github.com/vim/vim/commit/577922b917e48285a7a312daf7b5bbc6e272939c Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Diffstat (limited to 'runtime')
-rw-r--r--runtime/doc/builtin.txt20
1 files changed, 13 insertions, 7 deletions
diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt
index 27d52b7ac6..bdd9f2fd3a 100644
--- a/runtime/doc/builtin.txt
+++ b/runtime/doc/builtin.txt
@@ -1167,11 +1167,13 @@ charidx({string}, {idx} [, {countcc} [, {utf16}]])
When {utf16} is present and TRUE, {idx} is used as the UTF-16
index in the String {expr} instead of as the byte index.
- Returns -1 if the arguments are invalid or if {idx} is greater
- than the index of the last byte in {string}. An error is
- given if the first argument is not a string, the second
- argument is not a number or when the third argument is present
- and is not zero or one.
+ Returns -1 if the arguments are invalid or if there are less
+ than {idx} bytes. If there are exactly {idx} bytes the length
+ of the string in characters is returned.
+
+ An error is given and -1 is returned if the first argument is
+ not a string, the second argument is not a number or when the
+ third argument is present and is not zero or one.
See |byteidx()| and |byteidxcomp()| for getting the byte index
from the character index and |utf16idx()| for getting the
@@ -9138,8 +9140,8 @@ uniq({list} [, {func} [, {dict}]]) *uniq()* *E882*
<
*utf16idx()*
utf16idx({string}, {idx} [, {countcc} [, {charidx}]])
- Same as |charidx()| but returns the UTF-16 index of the byte
- at {idx} in {string} (after converting it to UTF-16).
+ Same as |charidx()| but returns the UTF-16 code unit index of
+ the byte at {idx} in {string} (after converting it to UTF-16).
When {charidx} is present and TRUE, {idx} is used as the
character index in the String {string} instead of as the byte
@@ -9147,6 +9149,10 @@ utf16idx({string}, {idx} [, {countcc} [, {charidx}]])
An {idx} in the middle of a UTF-8 sequence is rounded upwards
to the end of that sequence.
+ Returns -1 if the arguments are invalid or if there are less
+ than {idx} bytes in {string}. If there are exactly {idx} bytes
+ the length of the string in UTF-16 code units is returned.
+
See |byteidx()| and |byteidxcomp()| for getting the byte index
from the UTF-16 index and |charidx()| for getting the
character index from the UTF-16 index.