summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2020-11-25 16:50:42 +0800
committer最萌小汐 <sumneko@hotmail.com>2020-11-25 16:50:42 +0800
commit33580c1dd7c5ce0c9829e976cacd94418846eece (patch)
treedaedf3cd1148c1aca7f7a6618cc375515d9e6617
parent672bec919c9199b9d70856b04620a05f3a03bf58 (diff)
downloadlua-language-server-33580c1dd7c5ce0c9829e976cacd94418846eece.zip
fix path
-rw-r--r--script/core/hover/description.lua2
-rw-r--r--script/workspace/workspace.lua17
2 files changed, 11 insertions, 8 deletions
diff --git a/script/core/hover/description.lua b/script/core/hover/description.lua
index c3fdba99..57ab0b23 100644
--- a/script/core/hover/description.lua
+++ b/script/core/hover/description.lua
@@ -26,7 +26,7 @@ local function asStringInRequire(source, literal)
end
if result and #result > 0 then
for i, uri in ipairs(result) do
- local searcher = searchers and furi.decode(searchers[uri])
+ local searcher = searchers and searchers[uri]
uri = files.getOriginUri(uri)
local path = furi.decode(uri)
if files.eq(path:sub(1, #rootPath), rootPath) then
diff --git a/script/workspace/workspace.lua b/script/workspace/workspace.lua
index 31828245..f5431def 100644
--- a/script/workspace/workspace.lua
+++ b/script/workspace/workspace.lua
@@ -253,13 +253,15 @@ function m.findUrisByFilePath(path)
local posts = {}
for uri in files.eachFile() do
local pathLen = #path
- local uriLen = #uri
- local seg = uri:sub(uriLen - pathLen, uriLen - pathLen)
+ local curPath = furi.decode(files.getOriginUri(uri))
+ local curLen = #curPath
+ local seg = curPath:sub(curLen - pathLen, curLen - pathLen)
if seg == '/' or seg == '\\' or seg == '' then
- local see = uri:sub(uriLen - pathLen + 1, uriLen)
+ local see = curPath:sub(curLen - pathLen + 1, curLen)
if files.eq(see, path) then
results[#results+1] = uri
- posts[uri] = files.getOriginUri(uri):sub(1, uriLen - pathLen)
+ local post = curPath:sub(1, curLen - pathLen)
+ posts[uri] = post:gsub('^[/\\]+', '')
end
end
end
@@ -278,7 +280,7 @@ function m.findUrisByRequirePath(path)
local input = path:gsub('%.', '/')
:gsub('%%', '%%%%')
for _, luapath in ipairs(config.config.runtime.path) do
- local part = luapath:gsub('%?', input)
+ local part = m.normalize(luapath:gsub('%?', input))
local uris, posts = m.findUrisByFilePath(part)
for _, uri in ipairs(uris) do
if not mark[uri] then
@@ -302,13 +304,14 @@ function m.normalize(path)
path = path:gsub('[/\\]+', '/')
:gsub('[/\\]+$', '')
end
- return path:gsub('^[/\\]+', '')
+ return path
end
function m.getRelativePath(uri)
local path = furi.decode(uri)
if not m.path then
- return m.normalize(path)
+ local relative = m.normalize(path)
+ return relative:gsub('^[/\\]+', '')
end
local _, pos
if platform.OS == 'Windows' then