diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-11-19 17:09:27 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-11-19 17:09:27 +0800 |
commit | 6e5a6359717eb286b11431759ad3295ad4ae7978 (patch) | |
tree | 6d8d726a3be569d200ea6b565fdb6a0b978ded13 | |
parent | 01270bd5a047f9ec4dc83d34cda5a59980dd39e7 (diff) | |
download | lua-language-server-6e5a6359717eb286b11431759ad3295ad4ae7978.zip |
fix #807
-rw-r--r-- | changelog.md | 1 | ||||
-rw-r--r-- | script/core/command/solve.lua | 11 | ||||
-rw-r--r-- | script/core/diagnostics/ambiguity-1.lua | 16 |
3 files changed, 19 insertions, 9 deletions
diff --git a/changelog.md b/changelog.md index 239140ba..a5f4d316 100644 --- a/changelog.md +++ b/changelog.md @@ -5,6 +5,7 @@ * `FIX` [#798](https://github.com/sumneko/lua-language-server/issues/798) * `FIX` [#804](https://github.com/sumneko/lua-language-server/issues/804) * `FIX` [#806](https://github.com/sumneko/lua-language-server/issues/806) +* `FIX` [#807](https://github.com/sumneko/lua-language-server/issues/807) ## 2.4.9 `2021-11-18` 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) + )), } }, } diff --git a/script/core/diagnostics/ambiguity-1.lua b/script/core/diagnostics/ambiguity-1.lua index dbaa101d..f03f4361 100644 --- a/script/core/diagnostics/ambiguity-1.lua +++ b/script/core/diagnostics/ambiguity-1.lua @@ -26,12 +26,12 @@ local literalMap = { } return function (uri, callback) - local ast = files.getState(uri) - if not ast then + local state = files.getState(uri) + if not state then return end local text = files.getText(uri) - guide.eachSourceType(ast.ast, 'binary', function (source) + guide.eachSourceType(state.ast, 'binary', function (source) if source.op.type ~= 'or' then return end @@ -51,7 +51,10 @@ return function (uri, callback) callback { start = source.start, finish = source.finish, - message = lang.script('DIAG_AMBIGUITY_1', text:sub(first.start, first.finish)) + message = lang.script('DIAG_AMBIGUITY_1', text:sub( + guide.positionToOffset(state, first.start + 1), + guide.positionToOffset(state, first.finish) + )) } end end @@ -65,7 +68,10 @@ return function (uri, callback) callback { start = source.start, finish = source.finish, - message = lang.script('DIAG_AMBIGUITY_1', text:sub(second.start, second.finish)) + message = lang.script('DIAG_AMBIGUITY_1', text:sub( + guide.positionToOffset(state, second.start + 1), + guide.positionToOffset(state, second.finish) + )) } end end |