diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-01-28 20:28:14 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-01-28 20:28:14 +0800 |
commit | dc17984bcdd5afc7f74a05234b7f7f8a5eb7766d (patch) | |
tree | 3bd7d21d343e609e4ff55a0e11703da524121097 /script/files.lua | |
parent | 91ac06cc06ce136a9563a51fefea3680d937dc5c (diff) | |
download | lua-language-server-dc17984bcdd5afc7f74a05234b7f7f8a5eb7766d.zip |
fix files.offset
Diffstat (limited to 'script/files.lua')
-rw-r--r-- | script/files.lua | 12 |
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 |