diff options
author | sumneko <sumneko@hotmail.com> | 2019-04-28 12:03:44 +0800 |
---|---|---|
committer | sumneko <sumneko@hotmail.com> | 2019-04-28 12:03:44 +0800 |
commit | e815cc9495f15baa259e22d8a9d83b037f5cb831 (patch) | |
tree | e174afbf79055251bb82deb282baaf9a22d407f2 /server | |
parent | e6252422506c45dfb4c583ca2438cc090ea4a282 (diff) | |
download | lua-language-server-e815cc9495f15baa259e22d8a9d83b037f5cb831.zip |
修正一些bug
Diffstat (limited to 'server')
-rw-r--r-- | server/main.lua | 2 | ||||
-rw-r--r-- | server/src/core/completion.lua | 6 | ||||
-rw-r--r-- | server/src/utility.lua | 7 | ||||
-rw-r--r-- | server/src/vm/local.lua | 6 | ||||
-rw-r--r-- | server/test/completion/init.lua | 16 |
5 files changed, 28 insertions, 9 deletions
diff --git a/server/main.lua b/server/main.lua index 685fce01..ac7860c5 100644 --- a/server/main.lua +++ b/server/main.lua @@ -22,7 +22,7 @@ local function tryDebugger() log.info('Debugger startup, listen port: 11411') end -pcall(tryDebugger) +--pcall(tryDebugger) require 'utility' require 'global_protect' diff --git a/server/src/core/completion.lua b/server/src/core/completion.lua index f84243a5..8659901f 100644 --- a/server/src/core/completion.lua +++ b/server/src/core/completion.lua @@ -206,8 +206,9 @@ local function searchFieldsByChild(parent, word, source, map) end) end +---@param vm VM local function searchFields(vm, source, word, callback) - local parent = source:get 'parent' + local parent = source:get 'parent' or vm.env:getValue() if not parent then return end @@ -448,7 +449,8 @@ local function searchSource(vm, source, word, callback, pos) searchAsGlobal(vm, source, word, callback) return end - if source:get 'simple' then + if source:get 'simple' + and (source.type == 'name' or source.type == '.' or source.type == ':') then searchAsSuffix(vm, source, word, callback) return end diff --git a/server/src/utility.lua b/server/src/utility.lua index 34412a97..9bca93a5 100644 --- a/server/src/utility.lua +++ b/server/src/utility.lua @@ -24,17 +24,12 @@ function table.dump(tbl) if type(tbl) ~= 'table' then return ('%q'):format(tbl) end - local table_mark = {} local lines = {} lines[#lines+1] = '{' local function unpack(tbl, tab) - if table_mark[tbl] then - return '<Circle Table>' - end - if tab > 10 then + if tab > 100 then return '<Deep Table>' end - table_mark[tbl] = true local keys = {} for key in pairs(tbl) do if type(key) == 'string' then diff --git a/server/src/vm/local.lua b/server/src/vm/local.lua index 11e3c8de..c6e67dbf 100644 --- a/server/src/vm/local.lua +++ b/server/src/vm/local.lua @@ -113,6 +113,12 @@ function mt:shadow(old) group[#group+1] = self self._shadow = group + if not self:getSource() then + log.error(table.dump(self)) + log.error(table.dump(getmetatable(self))) + return + end + old:close(self:getSource().start - 1) end diff --git a/server/test/completion/init.lua b/server/test/completion/init.lua index 21a80509..9d8477f7 100644 --- a/server/test/completion/init.lua +++ b/server/test/completion/init.lua @@ -776,6 +776,22 @@ else$ } TEST [[ +local xpcal +xpcal$ +]] +{ + { + label = 'xpcal', + kind = CompletionItemKind.Variable, + }, + { + label = 'xpcall', + kind = CompletionItemKind.Function, + documentation = EXISTS, + } +} + +TEST [[ ---@$ ]] (EXISTS) |