@@ -28,7 +28,10 @@ local function getOnePath(uri, path, searcher)
28
28
: gsub (' %.[^%.]+$' , ' ' )
29
29
: gsub (' [/\\ %.]+' , separator )
30
30
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
32
35
local word = stemPath :sub (start , pos )
33
36
local newSearcher = stemSearcher :gsub (' %?' , (word :gsub (' %%' , ' %%%%' )))
34
37
if newSearcher == stemPath then
@@ -43,8 +46,12 @@ function m.getVisiblePath(suri, path)
43
46
local strict = config .get (suri , ' Lua.runtime.pathStrict' )
44
47
path = workspace .normalize (path )
45
48
local uri = furi .encode (path )
46
- local libraryPath = furi .decode (files .getLibraryUri (suri , uri ))
47
49
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 ))
48
55
local cache = scp :get (' visiblePath' ) or scp :set (' visiblePath' , {})
49
56
local result = cache [path ]
50
57
if not result then
@@ -62,9 +69,13 @@ function m.getVisiblePath(suri, path)
62
69
local pos = 1
63
70
if not isAbsolute then
64
71
if libraryPath then
65
- pos = # libraryPath + 2
72
+ currentPath = currentPath : sub ( # libraryPath + 2 )
66
73
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
68
79
end
69
80
end
70
81
repeat
@@ -89,6 +100,7 @@ function m.getVisiblePath(suri, path)
89
100
addRequireName (suri , uri , expect )
90
101
end
91
102
until not pos or strict
103
+ :: CONTINUE::
92
104
end
93
105
end
94
106
return result
0 commit comments