Skip to content

Commit

Permalink
Fix when match.translate_slashes is "off".
Browse files Browse the repository at this point in the history
clink.filematches() always converted forward slashes to backslashes,
related to #57.  But it shouldn't convert slashes there, and also it
wasn't correct to treat `../foo` as a relative path anyway, since CMD
actually interprets `foo/bar` as `foo /bar` -- the slash is interpreted
as a switch character, not as a path separator.

Additionally, this change also makes "off" mode preserve typed forward
slashes and backslashes (e.g. completing `/foo/` became `/foo\bar\`,
but the expected behavior is really `/foo/bar\`).
  • Loading branch information
chrisant996 committed Jun 11, 2024
1 parent da9b897 commit 71e5bdb
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion clink/lua/scripts/arguments.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2220,7 +2220,11 @@ local function file_matches_impl(match_word, exact)
return matches
end

local root = (path.getdirectory(word) or ""):gsub("/", "\\")
local root = (path.getdirectory(word) or "")
if word:find("^/", #root + 1) == #root + 1 then
-- Preserve forward slash after the directory part, when present.
root = root.."/"
end
if expanded then
root = rl.collapsetilde(root)
end
Expand Down

0 comments on commit 71e5bdb

Please sign in to comment.