diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-01-18 17:02:45 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-01-18 17:02:45 +0800 |
commit | 9e8901c5d09b4537a5741fd20dc5cc77c5a23dce (patch) | |
tree | e51ba03f013fcb40b994737f48ed60f10622b1ce /script/files.lua | |
parent | b7fdf179a9015e3bef83f89c5a0811f1a67ef4d0 (diff) | |
download | lua-language-server-9e8901c5d09b4537a5741fd20dc5cc77c5a23dce.zip |
`FIX` library files not recognized correctly
Diffstat (limited to 'script/files.lua')
-rw-r--r-- | script/files.lua | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/script/files.lua b/script/files.lua index 3ec942cb..009beba4 100644 --- a/script/files.lua +++ b/script/files.lua @@ -12,6 +12,7 @@ local guide = require 'parser.guide' local smerger = require 'string-merger' local progress = require "progress" local encoder = require 'encoder' +local scope = require 'workspace.scope' ---@class files local m = {} @@ -23,7 +24,6 @@ m.assocMatcher = nil function m.reset() m.openMap = {} - m.libraryMap = {} m.fileMap = {} m.dllMap = {} m.visible = {} @@ -110,12 +110,28 @@ end --- 是否是库文件 function m.isLibrary(uri) - return m.libraryMap[uri] ~= nil + for _, scp in ipairs(scope.folders) do + local map = scp:get 'libraryMap' + if map and map[uri] ~= nil then + return true + end + end + local map = scope.fallback:get 'libraryMap' + if map and map[uri] ~= nil then + return true + end + return false end --- 获取库文件的根目录 function m.getLibraryPath(uri) - return m.libraryMap[uri] + for _, scp in ipairs(scope.folders) do + local map = scp:get 'libraryMap' + if map and map[uri] ~= nil then + return scp.uri + end + end + return nil end ---@param scp scope |