diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2023-03-10 14:43:02 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2023-03-10 14:43:02 +0800 |
commit | bf5b93744887eea63b5efc48adcb8ed2ba16acf0 (patch) | |
tree | 784fd03e7cba9d679a3bf57193a9c375744a7577 /script | |
parent | 2b02965c82570b9fe45bc825a5828cb6d9cec9a2 (diff) | |
download | lua-language-server-bf5b93744887eea63b5efc48adcb8ed2ba16acf0.zip |
fix offset to finish pos in diff
#1949
Diffstat (limited to 'script')
-rw-r--r-- | script/core/semantic-tokens.lua | 9 | ||||
-rw-r--r-- | script/string-merger.lua | 4 |
2 files changed, 13 insertions, 0 deletions
diff --git a/script/core/semantic-tokens.lua b/script/core/semantic-tokens.lua index 3d322a3e..116f7e53 100644 --- a/script/core/semantic-tokens.lua +++ b/script/core/semantic-tokens.lua @@ -719,6 +719,9 @@ local function buildTokens(state, results) local deltaStartChar if deltaLine == 0 then deltaStartChar = startChar - lastStartChar + if deltaStartChar == 0 then + goto continue + end else deltaStartChar = startChar end @@ -731,6 +734,7 @@ local function buildTokens(state, results) tokens[len + 3] = finishPos.character - startPos.character -- length tokens[len + 4] = source.type tokens[len + 5] = source.modifieres or 0 + ::continue:: end return tokens end @@ -795,6 +799,10 @@ local function solveMultilineAndOverlapping(state, results) for token in tokens:pairs() do local startPos = converter.packPosition(state, token.start) local endPos = converter.packPosition(state, token.finish) + if startPos.line == endPos.line + and startPos.character == endPos.character then + goto continue + end if endPos.line == startPos.line or client.getAbility 'textDocument.semanticTokens.multilineTokenSupport' then new[#new+1] = { @@ -827,6 +835,7 @@ local function solveMultilineAndOverlapping(state, results) } end end + ::continue:: end return new diff --git a/script/string-merger.lua b/script/string-merger.lua index b2a63f02..65896575 100644 --- a/script/string-merger.lua +++ b/script/string-merger.lua @@ -127,6 +127,10 @@ function m.getOffsetBack(info, offset) finish = diff.finish end if not start or not finish then + if offset > diff.cstart + and offset < diff.cfinish then + return diff.finish, diff.finish + end local soff = offset - diff.cstart local pos = math.min(diff.start + soff, diff.finish) start = start or pos |