summaryrefslogtreecommitdiff
path: root/script-beta/proto/define.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2019-12-13 10:38:50 +0800
committer最萌小汐 <sumneko@hotmail.com>2019-12-13 10:38:50 +0800
commitde103324e510e4d8e7964064d32708273cbf2e4a (patch)
tree176aac155e8fca62ba229e513c4b5295f49777da /script-beta/proto/define.lua
parente656fc0315ed6062653f30de376466b42bb3eeaa (diff)
downloadlua-language-server-de103324e510e4d8e7964064d32708273cbf2e4a.zip
修正在文件末尾输入时自动完成失效的bug
Diffstat (limited to 'script-beta/proto/define.lua')
-rw-r--r--script-beta/proto/define.lua3
1 files changed, 2 insertions, 1 deletions
diff --git a/script-beta/proto/define.lua b/script-beta/proto/define.lua
index 61c4037c..3c955c95 100644
--- a/script-beta/proto/define.lua
+++ b/script-beta/proto/define.lua
@@ -11,7 +11,8 @@ function m.offset(lines, text, position)
local row = position.line + 1
local start = guide.lineRange(lines, row)
local offset = utf8.offset(text, position.character + 1, start)
- if text:sub(offset-1, offset):match '[%w_][^%w_]' then
+ if offset > #text
+ or text:sub(offset-1, offset):match '[%w_][^%w_]' then
offset = offset - 1
end
return offset