summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-09-24 11:54:59 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-09-24 11:54:59 +0800
commit05e9b84c2f9c0effbe5ae86c19fd390ba8067e17 (patch)
tree8af5f8b05238ee802e8914554f86f77ee237b2c6
parent9f73d326ccea763762cefd2866e477796221b10f (diff)
downloadlua-language-server-05e9b84c2f9c0effbe5ae86c19fd390ba8067e17.zip
fix
-rw-r--r--script/proto/converter.lua13
1 files changed, 6 insertions, 7 deletions
diff --git a/script/proto/converter.lua b/script/proto/converter.lua
index 5fb73c14..0ff07290 100644
--- a/script/proto/converter.lua
+++ b/script/proto/converter.lua
@@ -21,14 +21,13 @@ local function rawPackPosition(uri, pos)
}
end
-
-local function diffedPackPosition(uri, originPos)
+local function diffedPackPosition(uri, pos)
local state = files.getState(uri)
+ local offset = guide.positionToOffset(state, pos)
+ local originOffset = files.diffedOffsetBack(uri, offset)
local originLines = files.getOriginLines(uri)
- local originOffset = guide.positionToOffsetByLines(originLines, originPos)
- local offset = files.diffedOffsetBack(uri, originOffset)
- local pos = guide.offsetToPosition(state, offset)
- local row, col = guide.rowColOf(pos)
+ local originPos = guide.offsetToPositionByLines(originLines, originOffset)
+ local row, col = guide.rowColOf(originPos)
if col > 0 then
local text = files.getOriginText(uri)
if text then
@@ -80,7 +79,7 @@ local function diffedUnpackPosition(uri, position)
local state = files.getState(uri)
local originPos = guide.positionOf(row, col)
local originOffset = guide.positionToOffsetByLines(originLines, originPos)
- local offset = files.diffedOffset(originOffset)
+ local offset = files.diffedOffset(uri, originOffset)
local pos = guide.offsetToPosition(state, offset)
return pos
end