Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
sumneko committed May 18, 2021
1 parent 82190ca commit 4f1f6d4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
10 changes: 3 additions & 7 deletions script/workspace/workspace.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
12 changes: 12 additions & 0 deletions test/crossfile/definition.lua
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,18 @@ TEST {
},
}

TEST {
{
path = '@bbb.lua',
content = '',
target = {0, 0},
},
{
path = 'b.lua',
content = 'require "<?@bbb?>"',
},
}

TEST {
{
path = 'aaa/bbb.lua',
Expand Down

0 comments on commit 4f1f6d4

Please sign in to comment.