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 | |
parent | 061a23fc153a46c61673c5e46f9bbab46e1b22cf (diff) | |
parent | 6e5a6359717eb286b11431759ad3295ad4ae7978 (diff) | |
download | lua-language-server-8b1c6ac771a3a1bcc938863235b31580ba32b4ee.zip |
Merge branch 'bugfix'
Diffstat (limited to 'script')
-rw-r--r-- | script/config/config.lua | 2 | ||||
-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 | ||||
-rw-r--r-- | script/filewatch.lua | 9 | ||||
-rw-r--r-- | script/workspace/workspace.lua | 2 |
6 files changed, 40 insertions, 20 deletions
diff --git a/script/config/config.lua b/script/config/config.lua index 2f923d89..0e18428f 100644 --- a/script/config/config.lua +++ b/script/config/config.lua @@ -170,7 +170,7 @@ local Template = { ['Lua.diagnostics.workspaceRate'] = Type.Integer >> 100, ['Lua.diagnostics.libraryFiles'] = Type.String >> 'Opened', ['Lua.diagnostics.ignoredFiles'] = Type.String >> 'Opened', - ['Lua.workspace.ignoreDir'] = Type.Hash(Type.String, Type.Boolean, ';'), + ['Lua.workspace.ignoreDir'] = Type.Array(Type.String), ['Lua.workspace.ignoreSubmodules'] = Type.Boolean >> true, ['Lua.workspace.useGitIgnore'] = Type.Boolean >> true, ['Lua.workspace.maxPreload'] = Type.Integer >> 1000, 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 diff --git a/script/filewatch.lua b/script/filewatch.lua index 28f7376f..dd46d1a3 100644 --- a/script/filewatch.lua +++ b/script/filewatch.lua @@ -8,11 +8,14 @@ local RENAME = 1 << 1 local function exists(filename) local path = fs.path(filename) local suc, res = pcall(fs.exists, path) - if suc and res then - return true - else + if not suc or not res then return false end + suc, res = pcall(fs.canonical, path) + if not suc or res:string() ~= path:string() then + return false + end + return true end ---@class filewatch diff --git a/script/workspace/workspace.lua b/script/workspace/workspace.lua index de534a96..099196ce 100644 --- a/script/workspace/workspace.lua +++ b/script/workspace/workspace.lua @@ -131,7 +131,7 @@ function m.getNativeMatcher() end end -- config.get 'workspace.ignoreDir' - for path in pairs(config.get 'Lua.workspace.ignoreDir') do + for _, path in ipairs(config.get 'Lua.workspace.ignoreDir') do log.info('Ignore directory:', path) pattern[#pattern+1] = path end |