summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2020-10-26 16:45:06 +0800
committer最萌小汐 <sumneko@hotmail.com>2020-10-26 16:45:06 +0800
commit498554df7ae423a62d5ce3dcc93c7dff54209226 (patch)
tree3d9d1ed737104db3b33a9dda3b8d6246601b53a6
parente70ac18efc00ae438615650f6727693e93830217 (diff)
downloadlua-language-server-498554df7ae423a62d5ce3dcc93c7dff54209226.zip
再判断一下0
-rw-r--r--script-beta/proto/define.lua4
1 files changed, 2 insertions, 2 deletions
diff --git a/script-beta/proto/define.lua b/script-beta/proto/define.lua
index 124ca42c..4dd5215e 100644
--- a/script-beta/proto/define.lua
+++ b/script-beta/proto/define.lua
@@ -11,7 +11,7 @@ local m = {}
function m.offset(lines, text, position)
local row = position.line + 1
local start = guide.lineRange(lines, row)
- if start > #text then
+ if start <= 0 or start > #text then
return #text + 1
end
local offset = utf8.offset(text, position.character + 1, start)
@@ -26,7 +26,7 @@ end
function m.offsetOfWord(lines, text, position)
local row = position.line + 1
local start = guide.lineRange(lines, row)
- if start > #text then
+ if start <= 0 or start > #text then
return #text + 1
end
local offset = utf8.offset(text, position.character + 1, start)