summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-01-10 20:41:30 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-01-10 20:41:30 +0800
commite112035b49171693d2c492e329eae2df23ad0c87 (patch)
tree3be82b760d539a3ef0adab21bca75e82aeaf0223
parent14760a600837ec760fd9874bcc1076db4cfeb7dc (diff)
downloadlua-language-server-e112035b49171693d2c492e329eae2df23ad0c87.zip
fix
-rw-r--r--script/core/semantic-tokens.lua18
-rw-r--r--script/parser/guide.lua11
2 files changed, 19 insertions, 10 deletions
diff --git a/script/core/semantic-tokens.lua b/script/core/semantic-tokens.lua
index b4b05149..806615fe 100644
--- a/script/core/semantic-tokens.lua
+++ b/script/core/semantic-tokens.lua
@@ -474,12 +474,12 @@ local function solveMultilineAndOverlapping(state, results)
local startRow, startCol = guide.rowColOf(token.start)
local finishRow, finishCol = guide.rowColOf(token.finish)
if finishRow > startRow then
- token.finish = guide.positionOf(startRow, 9999)
+ token.finish = guide.positionOf(startRow, guide.getLineRange(state, startRow))
end
for i = startRow + 1, finishRow - 1 do
new[#new+1] = {
start = guide.positionOf(i, 0),
- finish = guide.positionOf(i, 9999),
+ finish = guide.positionOf(i, guide.getLineRange(state, i)),
type = token.type,
modifieres = token.modifieres,
}
@@ -487,7 +487,7 @@ local function solveMultilineAndOverlapping(state, results)
if finishCol > 0 then
new[#new+1] = {
start = guide.positionOf(finishRow, 0),
- finish = token.finish,
+ finish = guide.positionOf(finishRow, finishCol),
type = token.type,
modifieres = token.modifieres,
}
@@ -525,13 +525,11 @@ return function (uri, start, finish)
end)
for _, comm in ipairs(state.comms) do
- if comm.type == 'comment.cshort' then
- results[#results+1] = {
- start = comm.start,
- finish = comm.finish,
- type = define.TokenTypes.comment,
- }
- end
+ results[#results+1] = {
+ start = comm.start,
+ finish = comm.finish,
+ type = define.TokenTypes.comment,
+ }
end
if #results == 0 then
diff --git a/script/parser/guide.lua b/script/parser/guide.lua
index 544f3eaa..9c7f057d 100644
--- a/script/parser/guide.lua
+++ b/script/parser/guide.lua
@@ -802,6 +802,17 @@ function m.offsetToPosition(state, offset)
return m.offsetToPositionByLines(state.lines, offset)
end
+function m.getLineRange(state, row)
+ local nextLineStart = state.lines[row + 1] or #state.lua
+ for i = nextLineStart - 1, state.lines[row], -1 do
+ local w = state.lua:sub(i, i)
+ if w ~= '\r' and w ~= '\n' then
+ return i - state.lines[row] + 1
+ end
+ end
+ return 0
+end
+
local isSetMap = {
['setglobal'] = true,
['local'] = true,