summaryrefslogtreecommitdiff
path: root/script-beta
diff options
context:
space:
mode:
Diffstat (limited to 'script-beta')
-rw-r--r--script-beta/proto/define.lua6
1 files changed, 6 insertions, 0 deletions
diff --git a/script-beta/proto/define.lua b/script-beta/proto/define.lua
index 92403518..3afd5dc7 100644
--- a/script-beta/proto/define.lua
+++ b/script-beta/proto/define.lua
@@ -11,6 +11,9 @@ local m = {}
function m.offset(lines, text, position)
local row = position.line + 1
local start = guide.lineRange(lines, row)
+ if start >= #text then
+ return 0
+ end
local offset = utf8.offset(text, position.character + 1, start)
return offset - 1
end
@@ -23,6 +26,9 @@ end
function m.offsetOfWord(lines, text, position)
local row = position.line + 1
local start = guide.lineRange(lines, row)
+ if start >= #text then
+ return 0
+ end
local offset = utf8.offset(text, position.character + 1, start)
if offset > #text
or text:sub(offset-1, offset):match '[%w_][^%w_]' then