Fix space and escaped paren completions

This commit is contained in:
Jonathan Turner 2019-07-15 17:40:27 +12:00
parent 59115a532f
commit 5261d5f43f

View File

@ -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 {