summaryrefslogtreecommitdiff
path: root/script/core/command
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-11-19 17:09:27 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-11-19 17:09:27 +0800
commit6e5a6359717eb286b11431759ad3295ad4ae7978 (patch)
tree6d8d726a3be569d200ea6b565fdb6a0b978ded13 /script/core/command
parent01270bd5a047f9ec4dc83d34cda5a59980dd39e7 (diff)
downloadlua-language-server-6e5a6359717eb286b11431759ad3295ad4ae7978.zip
fix #807
Diffstat (limited to 'script/core/command')
-rw-r--r--script/core/command/solve.lua11
1 files changed, 7 insertions, 4 deletions
diff --git a/script/core/command/solve.lua b/script/core/command/solve.lua
index 9428d065..f7831f7f 100644
--- a/script/core/command/solve.lua
+++ b/script/core/command/solve.lua
@@ -30,14 +30,14 @@ local literalMap = {
return function (data)
local uri = data.uri
local text = files.getText(uri)
- local ast = files.getState(uri)
- if not ast then
+ local state = files.getState(uri)
+ if not state then
return
end
local start, finish = converter.unpackRange(uri, data.range)
- local result = guide.eachSourceContain(ast.ast, start, function (source)
+ local result = guide.eachSourceContain(state.ast, start, function (source)
if source.start ~= start
or source.finish ~= finish then
return
@@ -86,7 +86,10 @@ return function (data)
[uri] = {
{
range = converter.packRange(uri, result.start, result.finish),
- newText = ('(%s)'):format(text:sub(result.start, result.finish)),
+ newText = ('(%s)'):format(text:sub(
+ guide.positionToOffset(state, result.start + 1),
+ guide.positionToOffset(state, result.finish)
+ )),
}
},
}