diff options
-rw-r--r-- | script-beta/proto/define.lua | 4 |
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) |