summaryrefslogtreecommitdiff
path: root/script/workspace/require-path.lua
diff options
context:
space:
mode:
Diffstat (limited to 'script/workspace/require-path.lua')
-rw-r--r--script/workspace/require-path.lua34
1 files changed, 14 insertions, 20 deletions
diff --git a/script/workspace/require-path.lua b/script/workspace/require-path.lua
index 1e7c81e5..02b1996d 100644
--- a/script/workspace/require-path.lua
+++ b/script/workspace/require-path.lua
@@ -170,30 +170,24 @@ function mt:findUrisByRequireName(suri, name)
for _, searcher in ipairs(searchers) do
local fspath = searcher:gsub('%?', (path:gsub('%%', '%%%%')))
- local fullPath = workspace.getAbsolutePath(self.scp.uri, fspath)
- if fullPath then
- local fullUri = furi.encode(fullPath)
- if files.exists(fullUri)
- and fullUri ~= suri then
- results[#results+1] = fullUri
- searcherMap[fullUri] = searcher
- end
- end
+ fspath = workspace.normalize(fspath)
local tail = '/' .. furi.encode(fspath):gsub('^file:[/]*', '')
for uri in files.eachFile(self.scp.uri) do
- if not searcherMap[uri]
+ if not searcherMap[uri]
and suri ~= uri
and util.stringEndWith(uri, tail) then
- local parentUri = files.getLibraryUri(self.scp.uri, uri) or self.scp.uri
- if parentUri == nil or parentUri == '' then
- parentUri = furi.encode ''
- end
- local relative = uri:sub(#parentUri + 1):sub(1, - #tail)
- if not strict or relative == "/" then
- results[#results+1] = uri
- end
- searcherMap[uri] = workspace.normalize(relative .. searcher)
- end
+ local parentUri = files.getLibraryUri(self.scp.uri, uri) or self.scp.uri
+ if parentUri == nil or parentUri == '' then
+ parentUri = furi.encode '/'
+ end
+ local relative = uri:sub(#parentUri + 1):sub(1, - #tail)
+ if not strict
+ or relative == '/'
+ or relative == '' then
+ results[#results+1] = uri
+ searcherMap[uri] = workspace.normalize(relative .. searcher)
+ end
+ end
end
end