Be more lenient with appending `PATHSEP` in `common.path_suggest` in Windows

This allows to use the Unix separator without resulting in ugly 
suggestions that added the Windows separator too.

For example:
Before: `data/` -> `data/\core\`
After: `data/` -> `data/core\`
This commit is contained in:
Guldoman 2022-08-17 00:11:19 +02:00
parent e8ca861512
commit 4c186b07a3
No known key found for this signature in database
GPG Key ID: EA928C8BDA1A8825
1 changed files with 3 additions and 1 deletions

View File

@ -164,7 +164,9 @@ function common.path_suggest(text, root)
end
end
if path:sub(-1) ~= PATHSEP then
-- Only in Windows allow using both styles of PATHSEP
if (PATHSEP == "\\" and not string.match(path:sub(-1), "[\\/]")) or
(PATHSEP ~= "\\" and path:sub(-1) ~= PATHSEP) then
path = path .. PATHSEP
end
local files = system.list_dir(path) or {}