Skip to content

Commit

Permalink
Fix command-mode completion behavior when input is escaped
Browse files Browse the repository at this point in the history
If `a\ b.txt` were a local file, `:o a\ <tab>` would fill the prompt
with `:o aa\ b.txt` because the replacement range was calculated using
the shellwords-parsed part. Escaping the part before calculating its
length fixes this edge-case.
  • Loading branch information
the-mikedavis committed Nov 4, 2022
1 parent 7239fe2 commit 3cee767
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion helix-term/src/commands/typed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2219,12 +2219,15 @@ pub(super) fn command_mode(cx: &mut Context) {
..
}) = typed::TYPABLE_COMMAND_MAP.get(&command as &str)
{
let part_len = shellwords::escape(part.clone()).len();

completer(editor, &part)
.into_iter()
.map(|(range, file)| {
let file = shellwords::escape(file);

// offset ranges to input
let offset = input.len() - part.len();
let offset = input.len() - part_len;
let range = (range.start + offset)..;
(range, file)
})
Expand Down

0 comments on commit 3cee767

Please sign in to comment.