summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-09-22 11:30:39 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-09-22 11:30:39 +0800
commita847377582e5f22244aa587f9d79a07f9db03780 (patch)
tree2462bdbd70b7c1a303f3fb7159e032079d553051
parent621ee2b3e79dd452ddb3b96cf63a2bc2792b9254 (diff)
downloadlua-language-server-a847377582e5f22244aa587f9d79a07f9db03780.zip
update
-rw-r--r--script/core/keyword.lua13
-rw-r--r--script/parser/newparser.lua5
-rw-r--r--test/completion/common.lua2
3 files changed, 12 insertions, 8 deletions
diff --git a/script/core/keyword.lua b/script/core/keyword.lua
index b0c75f7e..295026d7 100644
--- a/script/core/keyword.lua
+++ b/script/core/keyword.lua
@@ -271,15 +271,16 @@ until $1"
return false
end},
{'then', function (info, results)
- local lines = files.getLines(info.uri)
- local pos, first = info.text:match('%S+%s+()(%S+)', info.start)
+ local startOffset = guide.positionToOffset(info.state, info.start)
+ local pos, first = info.text:match('%S+%s+()(%S+)', startOffset + 1)
if first == 'end'
or first == 'else'
or first == 'elseif' then
- local startRow = guide.rowColOf(info.start)
- local finishRow = guide.rowColOf(pos)
- local startSp = info.text:match('^%s*', lines[startRow].start + 1)
- local finishSp = info.text:match('^%s*', lines[finishRow].start + 1)
+ local startRow = guide.rowColOf(info.start)
+ local finishPosition = guide.offsetToPosition(info.state, pos)
+ local finishRow = guide.rowColOf(finishPosition)
+ local startSp = info.text:match('^%s*', info.state.lines[startRow])
+ local finishSp = info.text:match('^%s*', info.state.lines[finishRow])
if startSp == finishSp then
return false
end
diff --git a/script/parser/newparser.lua b/script/parser/newparser.lua
index 7955a5c3..de78fd6d 100644
--- a/script/parser/newparser.lua
+++ b/script/parser/newparser.lua
@@ -476,7 +476,9 @@ local function skipComment(isAction)
or (token == '//' and isAction) then
local start = Tokens[Index]
local left = getPosition(start, 'left')
+ local chead = false
if token == '//' then
+ chead = true
pushCommentHeadError(left)
end
Index = Index + 2
@@ -497,7 +499,7 @@ local function skipComment(isAction)
Index = Index + 2
end
State.comms[#State.comms+1] = {
- type = 'comment.shot',
+ type = chead and 'comment.cshort' or 'comment.short',
start = left,
finish = getPosition(Tokens[Index], 'right'),
text = ssub(Lua, start + 2, Tokens[Index] and (Tokens[Index] - 1) or #Lua),
@@ -1663,6 +1665,7 @@ local function parseSimple(node, funcName)
call.finish = getPosition(Tokens[Index], 'right')
Index = Index + 2
else
+ call.finish = lastRightPosition()
missSymbol ')'
end
if args then
diff --git a/test/completion/common.lua b/test/completion/common.lua
index d0ca92da..2f37ef38 100644
--- a/test/completion/common.lua
+++ b/test/completion/common.lua
@@ -1865,7 +1865,7 @@ f(<??>)
kind = define.CompletionItemKind.Function,
insertText = "\z
function (${1:x}, ${2:y})\
-\t<??>0\
+\t$0\
end",
},
}