diff options
author | sumneko <sumneko@hotmail.com> | 2021-10-02 04:23:26 +0800 |
---|---|---|
committer | sumneko <sumneko@hotmail.com> | 2021-10-02 04:23:26 +0800 |
commit | 6d4f656f261b64403b55c4318652854c8aeada93 (patch) | |
tree | bdfe42d5b1c3e8d328de8832293508f78289a1a8 /script | |
parent | 8d393d7631e324c69d254d0b4a34a11e7d8b4316 (diff) | |
download | lua-language-server-6d4f656f261b64403b55c4318652854c8aeada93.zip |
fix #700 fix #701 check nil
Diffstat (limited to 'script')
-rw-r--r-- | script/config/loader.lua | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/script/config/loader.lua b/script/config/loader.lua index c7af26d9..5874601e 100644 --- a/script/config/loader.lua +++ b/script/config/loader.lua @@ -17,8 +17,11 @@ end local m = {} function m.loadRCConfig(filename) - local path = fs.path(workspace.getAbsolutePath(filename)) - local buf = fsu.loadFile(path) + local path = workspace.getAbsolutePath(filename) + if not path then + return + end + local buf = util.loadFile(path) if not buf then return end @@ -31,10 +34,13 @@ function m.loadRCConfig(filename) end function m.loadLocalConfig(filename) - local path = fs.path(workspace.getAbsolutePath(filename)) - local buf = fsu.loadFile(path) + local path = workspace.getAbsolutePath(filename) + if not path then + return + end + local buf = util.loadFile(path) if not buf then - errorMessage(lang.script('CONFIG_LOAD_FAILED', path:string())) + errorMessage(lang.script('CONFIG_LOAD_FAILED', path)) return end local firstChar = buf:match '%S' @@ -47,7 +53,7 @@ function m.loadLocalConfig(filename) return res else local suc, res = pcall(function () - return assert(load(buf, '@' .. path:string(), 't'))() + return assert(load(buf, '@' .. path, 't'))() end) if not suc then errorMessage(lang.script('CONFIG_LOAD_ERROR', res)) |