From ea2795520e68db8737bd6d0ab7a93d5e5a482346 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Wed, 12 Oct 2022 16:33:29 +0800 Subject: cleanup --- script/workspace/require-path.lua | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) (limited to 'script/workspace/require-path.lua') 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 -- cgit v1.2.3