Remove dot slash from suggested paths in `common.path_suggest`
When no `root` is specified and the initial `path` is empty, the initial `path` becomes `.`. This results in returned files/dirs that are prepended with `./`. Now, in that case, `./` is removed.
This commit is contained in:
parent
6ccc5f6dde
commit
4b4c54ba65
|
@ -152,11 +152,13 @@ function common.path_suggest(text, root)
|
|||
root = root .. PATHSEP
|
||||
end
|
||||
local path, name = text:match("^(.-)([^/\\]*)$")
|
||||
local clean_dotslash = false
|
||||
-- ignore root if path is absolute
|
||||
local is_absolute = common.is_absolute_path(text)
|
||||
if not is_absolute then
|
||||
if path == "" then
|
||||
path = root or "."
|
||||
clean_dotslash = not root
|
||||
else
|
||||
path = (root or "") .. path
|
||||
end
|
||||
|
@ -180,6 +182,12 @@ function common.path_suggest(text, root)
|
|||
if s == 1 then
|
||||
file = file:sub(e + 1)
|
||||
end
|
||||
elseif clean_dotslash then
|
||||
-- remove added dot slash
|
||||
local s, e = file:find("." .. PATHSEP, nil, true)
|
||||
if s == 1 then
|
||||
file = file:sub(e + 1)
|
||||
end
|
||||
end
|
||||
if file:lower():find(text:lower(), nil, true) == 1 then
|
||||
table.insert(res, file)
|
||||
|
|
Loading…
Reference in New Issue