diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-05-18 20:59:16 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-05-19 16:07:12 +0800 |
commit | da6cee5ab4a06cbdd4d4d3b23ac7a43726459033 (patch) | |
tree | d8763b9fa01e67022e851f1b112dc03740b66052 | |
parent | 5b4a0d3c6a3bad62a3be10ea897ccfd26faabceb (diff) | |
download | lua-language-server-da6cee5ab4a06cbdd4d4d3b23ac7a43726459033.zip |
fix
-rw-r--r-- | script/workspace/workspace.lua | 10 | ||||
-rw-r--r-- | test/crossfile/definition.lua | 12 |
2 files changed, 15 insertions, 7 deletions
diff --git a/script/workspace/workspace.lua b/script/workspace/workspace.lua index 72a689c1..5350369e 100644 --- a/script/workspace/workspace.lua +++ b/script/workspace/workspace.lua @@ -329,11 +329,7 @@ function m.findUrisByFilePath(path) if type(path) ~= 'string' then return {} end - local lpath = path:gsub('[/\\]+', '/') - if lpath:match('^[/\\]') - or lpath:match('^%a+%:') then - lpath = furi.encode(lpath) - end + local lpath = furi.encode(path):gsub('^file:///', '') if platform.OS == 'Windows' then lpath = lpath:lower() end @@ -349,11 +345,11 @@ function m.findUrisByFilePath(path) if platform.OS ~= 'Windows' then uri = files.getOriginUri(uri) end - local curPath = furi.decode(files.getOriginUri(uri)) - if not curPath:find(lpath, 1, true) then + if not uri:find(lpath, 1, true) then goto CONTINUE end local pathLen = #path + 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 diff --git a/test/crossfile/definition.lua b/test/crossfile/definition.lua index fb0e872d..467e6af5 100644 --- a/test/crossfile/definition.lua +++ b/test/crossfile/definition.lua @@ -121,6 +121,18 @@ TEST { TEST { { + path = '@bbb.lua', + content = '', + target = {0, 0}, + }, + { + path = 'b.lua', + content = 'require "<?@bbb?>"', + }, +} + +TEST { + { path = 'aaa/bbb.lua', content = '', target = {0, 0}, |