aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src
diff options
context:
space:
mode:
authorMichael Davis2022-11-04 02:02:26 +0000
committerBlaž Hrastnik2022-11-07 04:38:16 +0000
commit140df92d7936e1fd036128d98ab565d92e9d2bd8 (patch)
tree450f4f94bcfd863b801991aad5ac04441daead2b /helix-term/src
parent3d283b2ca43bb077f52c48fec5e4870cd314b4e3 (diff)
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.
Diffstat (limited to 'helix-term/src')
-rw-r--r--helix-term/src/commands/typed.rs5
1 files changed, 4 insertions, 1 deletions
diff --git a/helix-term/src/commands/typed.rs b/helix-term/src/commands/typed.rs
index 36080d39..2f387bfd 100644
--- a/helix-term/src/commands/typed.rs
+++ b/helix-term/src/commands/typed.rs
@@ -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)
})