summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-01-28 20:28:14 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-01-28 20:28:14 +0800
commitdc17984bcdd5afc7f74a05234b7f7f8a5eb7766d (patch)
tree3bd7d21d343e609e4ff55a0e11703da524121097 /script
parent91ac06cc06ce136a9563a51fefea3680d937dc5c (diff)
downloadlua-language-server-dc17984bcdd5afc7f74a05234b7f7f8a5eb7766d.zip
fix files.offset
Diffstat (limited to 'script')
-rw-r--r--script/files.lua12
1 files changed, 6 insertions, 6 deletions
diff --git a/script/files.lua b/script/files.lua
index 7d43f39e..b3447cc4 100644
--- a/script/files.lua
+++ b/script/files.lua
@@ -453,14 +453,14 @@ function m.offset(uri, position)
local start = guide.lineRange(lines, row)
local offset
if start <= 0 or start > #text then
- offset = #text + 2
+ offset = #text
else
- offset = utf8.offset(text, position.character + 1, start) or (#text + 2)
+ offset = utf8.offset(text, position.character + 1, start) or #text
end
if file._diffInfo then
offset = smerger.getOffset(file._diffInfo, offset)
end
- return offset - 1
+ return offset
end
--- 获取 position 对应的光标位置(根据附近的单词)
@@ -482,9 +482,9 @@ function m.offsetOfWord(uri, position)
local start = guide.lineRange(lines, row)
local offset
if start <= 0 or start > #text then
- offset = #text + 2
+ offset = #text
else
- offset = utf8.offset(text, position.character + 1, start) or (#text + 2)
+ offset = utf8.offset(text, position.character + 1, start) or #text
end
if offset > #text
or text:sub(offset-1, offset):match '[%w_][^%w_]' then
@@ -493,7 +493,7 @@ function m.offsetOfWord(uri, position)
if file._diffInfo then
offset = smerger.getOffset(file._diffInfo, offset)
end
- return offset - 1
+ return offset
end
--- 将应用差异前的offset转换为应用差异后的offset