From 1a0f6e3aa420afff9028c4db6261f8faa6fa2ba6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Fri, 24 Sep 2021 17:31:53 +0800 Subject: check nil --- script/proto/converter.lua | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'script/proto') 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) -- cgit v1.2.3