console.lua: don't complete DLLs on Windows

run completion on Windows is slow because system32 contains thousands of
DLLs, so filter executables with an extension in PATHEXT.
This commit is contained in:
Guido Cella authored and Kacper Michajłow committed 2024-12-02 20:56:49 +01:00
1 parent 3053797e3c
commit 9d67fc28e2
1 file changed
+8 -1
+8 -1
View File
@@ -1343,10 +1343,17 @@ local function list_executables()
local executable_map = {}
local path = os.getenv('PATH') or ''
local separator = platform == 'windows' and ';' or ':'
local exts = {}
for ext in (os.getenv('PATHEXT') or ''):gmatch('[^;]+') do
exts[ext:lower()] = true
end
for directory in path:gmatch('[^' .. separator .. ']+') do
for _, executable in pairs(utils.readdir(directory, 'files') or {}) do
executable_map[executable] = true
if not next(exts) or exts[(executable:match('%.%w+$') or ''):lower()] then
executable_map[executable] = true
end
end
end