From 8584b38cfbe6ffe3e5d539ad953c413e44e90bfa Mon Sep 17 00:00:00 2001 From: Armin Ronacher Date: Tue, 1 Nov 2022 12:48:37 +0100 Subject: Correctly handle escaping in completion (#4316) * Correctly handle escaping in completion * Added escaping tests--- helix-term/src/commands/typed.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'helix-term/src/commands/typed.rs') diff --git a/helix-term/src/commands/typed.rs b/helix-term/src/commands/typed.rs index 0cf75ada..f4dfce7a 100644 --- a/helix-term/src/commands/typed.rs +++ b/helix-term/src/commands/typed.rs @@ -2183,12 +2183,10 @@ pub(super) fn command_mode(cx: &mut Context) { static FUZZY_MATCHER: Lazy = Lazy::new(fuzzy_matcher::skim::SkimMatcherV2::default); - // we use .this over split_whitespace() because we care about empty segments - let parts = input.split(' ').collect::>(); - // simple heuristic: if there's no just one part, complete command name. // if there's a space, per command completion kicks in. - if parts.len() <= 1 { + // we use .this over split_whitespace() because we care about empty segments + if input.split(' ').count() <= 1 { let mut matches: Vec<_> = typed::TYPABLE_COMMAND_LIST .iter() .filter_map(|command| { @@ -2204,12 +2202,13 @@ pub(super) fn command_mode(cx: &mut Context) { .map(|(name, _)| (0.., name.into())) .collect() } else { + let parts = shellwords::shellwords(input); let part = parts.last().unwrap(); if let Some(typed::TypableCommand { completer: Some(completer), .. - }) = typed::TYPABLE_COMMAND_MAP.get(parts[0]) + }) = typed::TYPABLE_COMMAND_MAP.get(&parts[0] as &str) { completer(editor, part) .into_iter() -- cgit v1.2.3-70-g09d2