diff options
Diffstat (limited to 'script/core/command')
-rw-r--r-- | script/core/command/solve.lua | 11 |
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) + )), } }, } |