summaryrefslogtreecommitdiff
path: root/script/proto
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-09-24 17:31:53 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-09-24 17:31:53 +0800
commit1a0f6e3aa420afff9028c4db6261f8faa6fa2ba6 (patch)
treee3335abc53a348a837c3b82b0b82a919e017e1e8 /script/proto
parente5a094cfc9ecaaea9873905b37658b9227c8fe99 (diff)
downloadlua-language-server-1a0f6e3aa420afff9028c4db6261f8faa6fa2ba6.zip
check nil
Diffstat (limited to 'script/proto')
-rw-r--r--script/proto/converter.lua10
1 files changed, 8 insertions, 2 deletions
diff --git a/script/proto/converter.lua b/script/proto/converter.lua
index 0ff07290..19d592fe 100644
--- a/script/proto/converter.lua
+++ b/script/proto/converter.lua
@@ -59,7 +59,10 @@ local function rawUnpackPosition(uri, position)
local text = files.getText(uri)
if text then
local lineOffset = state.lines[row]
- col = utf8.offset(text, col + 1, lineOffset) - lineOffset
+ local textOffset = utf8.offset(text, col + 1, lineOffset)
+ if textOffset then
+ col = textOffset - lineOffset
+ end
end
end
local pos = guide.positionOf(row, col)
@@ -73,7 +76,10 @@ local function diffedUnpackPosition(uri, position)
local text = files.getOriginText(uri)
if text then
local lineOffset = originLines[row]
- col = utf8.offset(text, col + 1, lineOffset) - lineOffset
+ local textOffset = utf8.offset(text, col + 1, lineOffset)
+ if textOffset then
+ col = textOffset - lineOffset
+ end
end
end
local state = files.getState(uri)