summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-07-21 14:43:05 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-07-21 14:43:05 +0800
commitf2f6e87895b83e6434dce2c4493042799311f52f (patch)
tree3787cb813a57498ae82edde80c48a428923b3259
parentbc6dd9b20925d21e6def32170854b27f69ca50d9 (diff)
downloadlua-language-server-f2f6e87895b83e6434dce2c4493042799311f52f.zip
safer `utf8.len`
-rw-r--r--script/files.lua8
1 files changed, 4 insertions, 4 deletions
diff --git a/script/files.lua b/script/files.lua
index 52607c99..c21cd211 100644
--- a/script/files.lua
+++ b/script/files.lua
@@ -610,12 +610,12 @@ function m.offset(uri, position, isFinish)
local start, finish, char
if row > #lines then
start, finish = guide.lineRange(lines, #lines)
- char = utf8.len(text, start, finish)
+ char = utf8.len(text, start, finish, true)
else
start, finish = guide.lineRange(lines, row)
char = position.character
end
- local utf8Len = utf8.len(text, start, finish)
+ local utf8Len = utf8.len(text, start, finish, true)
local offset
if char <= 0 then
offset = start
@@ -661,12 +661,12 @@ function m.offsetOfWord(uri, position)
local start, finish, char
if row > #lines then
start, finish = guide.lineRange(lines, #lines)
- char = utf8.len(text, start, finish)
+ char = utf8.len(text, start, finish, true)
else
start, finish = guide.lineRange(lines, row)
char = position.character
end
- local utf8Len = utf8.len(text, start, finish)
+ local utf8Len = utf8.len(text, start, finish, true)
local offset
if char <= 0 then
offset = start