Merge pull request #175 from jonathandturner/improve_path_completions

Fix space and escaped paren completions
This commit is contained in:
Jonathan Turner 2019-07-15 18:22:02 +12:00 committed by GitHub
commit c6bbcf723f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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 {