diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2018-12-08 19:29:40 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2018-12-08 19:29:40 +0800 |
commit | f76813d8a2e4ae3204b549259fe714806807e03d (patch) | |
tree | 2386f6a295cedc9de5544455f904a4f1d97e64db /server | |
parent | 4fcc1fda1276fad2daf6c09e2ffddc8c01206aae (diff) | |
download | lua-language-server-f76813d8a2e4ae3204b549259fe714806807e03d.zip |
修正找lib的一个bug
Diffstat (limited to 'server')
-rw-r--r-- | server/src/matcher/find_lib.lua | 20 | ||||
-rw-r--r-- | server/test/find_lib/init.lua | 5 |
2 files changed, 14 insertions, 11 deletions
diff --git a/server/src/matcher/find_lib.lua b/server/src/matcher/find_lib.lua index 3d98aef7..f24dabd4 100644 --- a/server/src/matcher/find_lib.lua +++ b/server/src/matcher/find_lib.lua @@ -179,9 +179,6 @@ local function checkParentAsObject(parentValue, name, parent) end local function checkParent(value, name, lib) - if not lib.parent then - return nil - end if name ~= value.key then return nil end @@ -214,13 +211,16 @@ end local function findLib(var, libs) local value = var.value or var for libname, lib in pairs(libs) do - local fullKey = checkSource(value, libname, lib) - if fullKey then - return lib, fullKey, false - end - local fullKey, oo = checkParent(value, libname, lib) - if fullKey then - return lib, fullKey, oo + if lib.parent then + local fullKey, oo = checkParent(value, libname, lib) + if fullKey then + return lib, fullKey, oo + end + else + local fullKey = checkSource(value, libname, lib) + if fullKey then + return lib, fullKey, false + end end end return nil, nil, nil diff --git a/server/test/find_lib/init.lua b/server/test/find_lib/init.lua index 09f0997d..e317c500 100644 --- a/server/test/find_lib/init.lua +++ b/server/test/find_lib/init.lua @@ -21,7 +21,6 @@ function TEST(fullkey) local var = result.var assert(var) local _, name = findLib(var) - assert(name) assert(name == fullkey) end end @@ -102,3 +101,7 @@ local filesystem = require 'bee.filesystem' ROOT = filesystem.<?current_path?>() ]] + +TEST(nil)[[ +print(<?insert?>) +]] |