diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-11-19 17:10:28 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-11-19 17:10:28 +0800 |
commit | 8b1c6ac771a3a1bcc938863235b31580ba32b4ee (patch) | |
tree | ae235ffb410cdb77a8cc2d7a3fe0595c2a727639 /script/core | |
parent | 061a23fc153a46c61673c5e46f9bbab46e1b22cf (diff) | |
parent | 6e5a6359717eb286b11431759ad3295ad4ae7978 (diff) | |
download | lua-language-server-8b1c6ac771a3a1bcc938863235b31580ba32b4ee.zip |
Merge branch 'bugfix'
Diffstat (limited to 'script/core')
-rw-r--r-- | script/core/command/solve.lua | 11 | ||||
-rw-r--r-- | script/core/diagnostics/ambiguity-1.lua | 16 | ||||
-rw-r--r-- | script/core/noder.lua | 20 |
3 files changed, 32 insertions, 15 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) + )), } }, } 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 diff --git a/script/core/noder.lua b/script/core/noder.lua index 12dcc3c7..0fc83905 100644 --- a/script/core/noder.lua +++ b/script/core/noder.lua @@ -940,7 +940,10 @@ compileNodeMap = util.switch() : call(function (noders, id, source) if source.bindSources then for _, src in ipairs(source.bindSources) do - pushForward(noders, getID(src), id) + if src.parent.type ~= 'funcargs' + and not src.dummy then + pushForward(noders, getID(src), id) + end end end for _, enumUnit in ipairs(source.enums) do @@ -954,7 +957,10 @@ compileNodeMap = util.switch() pushForward(noders, id, unitID) if source.bindSources then for _, src in ipairs(source.bindSources) do - pushBackward(noders, unitID, getID(src)) + if src.parent.type ~= 'funcargs' + and not src.dummy then + pushBackward(noders, unitID, getID(src)) + end end end end @@ -1031,8 +1037,11 @@ compileNodeMap = util.switch() or src.type == 'tablefield' or src.type == 'tableindex' or src.type == 'setglobal' then - pushForward(noders, getID(src), id) - pushForward(noders, id, getID(src)) + if src.parent.type ~= 'funcargs' + and not src.dummy then + pushForward(noders, getID(src), id) + pushForward(noders, id, getID(src)) + end end end end @@ -1372,8 +1381,7 @@ compileNodeMap = util.switch() end for _, rtn in ipairs(source.returns) do for _, src in ipairs(source.bindSources) do - if src.type == 'function' - or guide.isSet(src) then + if src.type == 'function' then local fullID = sformat('%s%s%s' , getID(src) , RETURN_INDEX |