summaryrefslogtreecommitdiff
path: root/script/workspace/require-path.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-10-12 16:33:29 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-10-12 16:33:29 +0800
commitea2795520e68db8737bd6d0ab7a93d5e5a482346 (patch)
tree5f21f8392ad123497f52ab893e79cb3013879456 /script/workspace/require-path.lua
parent896a1affdeed8304688611674df88140a5cc180e (diff)
downloadlua-language-server-ea2795520e68db8737bd6d0ab7a93d5e5a482346.zip
cleanup
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