@@ -28,7 +28,10 @@ local function getOnePath(uri, path, searcher)
2828 : gsub (' %.[^%.]+$' , ' ' )
2929 : gsub (' [/\\ %.]+' , separator )
3030 local start = stemSearcher :match ' ()%?' or 1
31- for pos = start , # stemPath do
31+ if stemPath :sub (1 , start - 1 ) ~= stemSearcher :sub (1 , start - 1 ) then
32+ return nil
33+ end
34+ for pos = # stemPath , start , - 1 do
3235 local word = stemPath :sub (start , pos )
3336 local newSearcher = stemSearcher :gsub (' %?' , (word :gsub (' %%' , ' %%%%' )))
3437 if newSearcher == stemPath then
@@ -43,8 +46,12 @@ function m.getVisiblePath(suri, path)
4346 local strict = config .get (suri , ' Lua.runtime.pathStrict' )
4447 path = workspace .normalize (path )
4548 local uri = furi .encode (path )
46- local libraryPath = furi .decode (files .getLibraryUri (suri , uri ))
4749 local scp = scope .getScope (suri )
50+ if not scp :isChildUri (uri )
51+ and not scp :isLinkedUri (uri ) then
52+ return {}
53+ end
54+ local libraryPath = furi .decode (files .getLibraryUri (suri , uri ))
4855 local cache = scp :get (' visiblePath' ) or scp :set (' visiblePath' , {})
4956 local result = cache [path ]
5057 if not result then
@@ -62,9 +69,13 @@ function m.getVisiblePath(suri, path)
6269 local pos = 1
6370 if not isAbsolute then
6471 if libraryPath then
65- pos = # libraryPath + 2
72+ currentPath = currentPath : sub ( # libraryPath + 2 )
6673 else
67- currentPath = workspace .getRelativePath (uri )
74+ local isRelative
75+ currentPath , isRelative = workspace .getRelativePath (uri )
76+ if not isAbsolute and not isRelative then
77+ goto CONTINUE
78+ end
6879 end
6980 end
7081 repeat
@@ -89,6 +100,7 @@ function m.getVisiblePath(suri, path)
89100 addRequireName (suri , uri , expect )
90101 end
91102 until not pos or strict
103+ :: CONTINUE::
92104 end
93105 end
94106 return result
0 commit comments