30
30
function m .getVisiblePath (path )
31
31
local searchers = config .get ' Lua.runtime.path'
32
32
local strict = config .get ' Lua.runtime.pathStrict'
33
- path = path : gsub ( ' ^[/ \\ ]+ ' , ' ' )
33
+ path = workspace . normalize ( path )
34
34
local uri = furi .encode (path )
35
35
local libraryPath = files .getLibraryPath (uri )
36
36
if not m .cache [path ] then
@@ -42,6 +42,7 @@ function m.getVisiblePath(path)
42
42
for _ , searcher in ipairs (searchers ) do
43
43
local isAbsolute = searcher :match ' ^[/\\ ]'
44
44
or searcher :match ' ^%a+%:'
45
+ searcher = workspace .normalize (searcher )
45
46
local cutedPath = path
46
47
local currentPath = path
47
48
local head
@@ -87,37 +88,36 @@ function m.findUrisByRequirePath(path)
87
88
if type (path ) ~= ' string' then
88
89
return {}
89
90
end
91
+ local separator = config .get ' Lua.completion.requireSeparator'
92
+ local fspath = path :gsub (' %' .. separator , ' /' )
90
93
local vm = require ' vm'
91
94
local cache = vm .getCache ' findUrisByRequirePath'
92
95
if cache [path ] then
93
96
return cache [path ].results , cache [path ].searchers
94
97
end
95
98
tracy .ZoneBeginN (' findUrisByRequirePath' )
96
99
local results = {}
97
- local mark = {}
98
100
local searchers = {}
99
101
for uri in files .eachDll () do
100
102
local opens = files .getDllOpens (uri ) or {}
101
103
for _ , open in ipairs (opens ) do
102
- if open == path then
104
+ if open == fspath then
103
105
results [# results + 1 ] = uri
104
106
end
105
107
end
106
108
end
107
109
108
- local input = path :gsub (' %.' , ' /' )
109
- :gsub (' %%' , ' %%%%' )
110
- for _ , luapath in ipairs (config .get ' Lua.runtime.path' ) do
111
- local part = workspace .normalize (luapath :gsub (' %?' , input ))
112
- local uris , posts = workspace .findUrisByFilePath (part )
113
- for _ , uri in ipairs (uris ) do
114
- if not mark [uri ] then
115
- mark [uri ] = true
110
+ for uri in files .eachFile () do
111
+ local infos = m .getVisiblePath (furi .decode (uri ))
112
+ for _ , info in ipairs (infos ) do
113
+ local fsexpect = info .expect :gsub (' %' .. separator , ' /' )
114
+ if fsexpect == fspath then
116
115
results [# results + 1 ] = uri
117
- searchers [uri ] = posts [ uri ] .. luapath
116
+ searchers [uri ] = info . searcher
118
117
end
119
118
end
120
119
end
120
+
121
121
tracy .ZoneEnd ()
122
122
cache [path ] = {
123
123
results = results ,
0 commit comments