summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--script/files.lua11
-rw-r--r--script/workspace/require-path.lua5
2 files changed, 6 insertions, 10 deletions
diff --git a/script/files.lua b/script/files.lua
index b6075d0c..1f54f441 100644
--- a/script/files.lua
+++ b/script/files.lua
@@ -124,12 +124,11 @@ function m.isLibrary(uri)
end
--- 获取库文件的根目录
-function m.getLibraryUri(uri)
- for _, scp in ipairs(scope.folders) do
- local map = scp:get 'libraryMap'
- if map and map[uri] ~= nil then
- return map[uri]
- end
+function m.getLibraryUri(suri, uri)
+ local scp = scope.getScope(suri)
+ local map = scp:get 'libraryMap'
+ if map and map[uri] ~= nil then
+ return map[uri]
end
return nil
end
diff --git a/script/workspace/require-path.lua b/script/workspace/require-path.lua
index 98e9e61c..223d6ada 100644
--- a/script/workspace/require-path.lua
+++ b/script/workspace/require-path.lua
@@ -43,15 +43,12 @@ function m.getVisiblePath(suri, path)
local strict = config.get(suri, 'Lua.runtime.pathStrict')
path = workspace.normalize(path)
local uri = furi.encode(path)
- local libraryPath = furi.decode(files.getLibraryUri(uri))
+ local libraryPath = furi.decode(files.getLibraryUri(suri, uri))
local scp = scope.getScope(suri)
local cache = scp:get('visiblePath') or scp:set('visiblePath', {})
if not cache[path] then
local result = {}
cache[path] = result
- if libraryPath then
- libraryPath = libraryPath:gsub('^[/\\]+', '')
- end
for _, searcher in ipairs(searchers) do
local isAbsolute = searcher:match '^[/\\]'
or searcher:match '^%a+%:'