mirror of https://github.com/helix-editor/helix
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
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)
|
}) = typed::TYPABLE_COMMAND_MAP.get(&parts[0] as &str)
|
||||||
{
|
{
|
||||||
|
let part_len = shellwords::escape(part.clone()).len();
|
||||||
|
|
||||||
completer(editor, part)
|
completer(editor, part)
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|(range, file)| {
|
.map(|(range, file)| {
|
||||||
let file = shellwords::escape(file);
|
let file = shellwords::escape(file);
|
||||||
|
|
||||||
// offset ranges to input
|
// offset ranges to input
|
||||||
let offset = input.len() - part.len();
|
let offset = input.len() - part_len;
|
||||||
let range = (range.start + offset)..;
|
let range = (range.start + offset)..;
|
||||||
(range, file)
|
(range, file)
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue