summaryrefslogtreecommitdiff
path: root/script/core/command
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-11-19 17:10:28 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-11-19 17:10:28 +0800
commit8b1c6ac771a3a1bcc938863235b31580ba32b4ee (patch)
treeae235ffb410cdb77a8cc2d7a3fe0595c2a727639 /script/core/command
parent061a23fc153a46c61673c5e46f9bbab46e1b22cf (diff)
parent6e5a6359717eb286b11431759ad3295ad4ae7978 (diff)
downloadlua-language-server-8b1c6ac771a3a1bcc938863235b31580ba32b4ee.zip
Merge branch 'bugfix'
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 19148092..8065aa9d 100644
--- a/script/core/command/solve.lua
+++ b/script/core/command/solve.lua
@@ -31,14 +31,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
@@ -87,7 +87,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)
+ )),
}
},
}