Fix command-mode completion behavior when input is escaped

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.
pull/4626/head
Michael Davis 2 years ago committed by Blaž Hrastnik
parent 3d283b2ca4
commit 140df92d79

@ -2216,12 +2216,15 @@ pub(super) fn command_mode(cx: &mut Context) {
..
}) = typed::TYPABLE_COMMAND_MAP.get(&parts[0] 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)
})

Loading…
Cancel
Save