From 5261d5f43fc5dcf936fe41e0c3a91c47c988a33b Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Mon, 15 Jul 2019 17:40:27 +1200 Subject: [PATCH] Fix space and escaped paren completions --- src/shell/completer.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/shell/completer.rs b/src/shell/completer.rs index 6501ff98b9..bcd8577af8 100644 --- a/src/shell/completer.rs +++ b/src/shell/completer.rs @@ -23,6 +23,24 @@ impl Completer for NuCompleter { let mut completions = self.file_completer.complete(line, pos, context)?.1; + for completion in &mut completions { + if completion.replacement.contains("\\ ") { + completion.replacement = completion.replacement.replace("\\ ", " "); + } + if completion.replacement.contains("\\(") { + completion.replacement = completion.replacement.replace("\\(", "("); + } + + if completion.replacement.contains(" ") || completion.replacement.contains("(") { + if !completion.replacement.starts_with("\"") { + completion.replacement = format!("\"{}", completion.replacement); + } + if !completion.replacement.ends_with("\"") { + completion.replacement = format!("{}\"", completion.replacement); + } + } + } + let line_chars: Vec<_> = line.chars().collect(); let mut replace_pos = pos; while replace_pos > 0 {