@@ -39,7 +39,7 @@ function mt:getRequireNameByPath(path, searcher)
3939 : gsub (' [/\\ %.]+' , separator )
4040 local stemSearcher = searcher
4141 : gsub (' %.[^%.]+$' , ' ' )
42- : gsub (' [/\\ %. ]+' , separator )
42+ : gsub (' [/\\ ]+' , separator )
4343 local start = stemSearcher :match ' ()%?' or 1
4444 if stemPath :sub (1 , start - 1 ) ~= stemSearcher :sub (1 , start - 1 ) then
4545 return nil
5858--- @return require-manager.visibleResult[]
5959function mt :getRequireResultByPath (path )
6060 local uri = furi .encode (path )
61- local searchers = config .get (self .scp .uri , ' Lua.runtime.path' )
62- local strict = config .get (self .scp .uri , ' Lua.runtime.pathStrict' )
63- local libUri = files .getLibraryUri (self .scp .uri , uri )
61+ local searchers = config .get (self .scp .uri , ' Lua.runtime.path' )
62+ local strict = config .get (self .scp .uri , ' Lua.runtime.pathStrict' )
63+ local libUri = files .getLibraryUri (self .scp .uri , uri )
6464 local libraryPath = libUri and furi .decode (libUri )
6565 local result = {}
6666 for _ , searcher in ipairs (searchers ) do
6767 local isAbsolute = searcher :match ' ^[/\\ ]'
6868 or searcher :match ' ^%a+%:'
6969 searcher = workspace .normalize (searcher )
70+ if searcher :sub (1 , 1 ) == ' .' then
71+ strict = true
72+ end
7073 local cutedPath = path
7174 local currentPath = path
7275 local head
@@ -78,6 +81,29 @@ function mt:getRequireResultByPath(path)
7881 currentPath = workspace .getRelativePath (uri )
7982 end
8083 end
84+
85+ -- handle `../?.lua`
86+ local parentCount = 0
87+ for _ = 1 , 1000 do
88+ if searcher :match ' ^%.%.[/\\ ]' then
89+ parentCount = parentCount + 1
90+ searcher = searcher :sub (4 )
91+ else
92+ break
93+ end
94+ end
95+ if parentCount > 0 then
96+ local parentPath = libraryPath
97+ or (self .scp .uri and furi .decode (self .scp .uri ))
98+ if parentPath then
99+ local tail
100+ for _ = 1 , parentCount do
101+ parentPath , tail = parentPath :match ' ^(.+)[/\\ ]([^/\\ ]*)$'
102+ currentPath = tail .. ' /' .. currentPath
103+ end
104+ end
105+ end
106+
81107 repeat
82108 cutedPath = currentPath :sub (pos )
83109 head = currentPath :sub (1 , pos - 1 )
0 commit comments