From bc6fa85a4b34330e9ca9c0c5d7e791c90a87d0dd Mon Sep 17 00:00:00 2001 From: JT Date: Tue, 8 Jun 2021 18:56:36 +1200 Subject: [PATCH] Fix completion crash (#3574) --- crates/nu-cli/src/shell/completer.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/crates/nu-cli/src/shell/completer.rs b/crates/nu-cli/src/shell/completer.rs index e7d70ae4b..9c0696d30 100644 --- a/crates/nu-cli/src/shell/completer.rs +++ b/crates/nu-cli/src/shell/completer.rs @@ -54,7 +54,14 @@ impl NuCompleter { if locations.is_empty() { (pos, Vec::new()) } else { - let pos = locations[0].span.start(); + let mut pos = locations[0].span.start(); + + for location in &locations { + if location.span.start() < pos { + pos = location.span.start(); + } + } + let suggestions = locations .into_iter() .flat_map(|location| {