diff --git a/crates/nu-cli/src/shell/completer.rs b/crates/nu-cli/src/shell/completer.rs index a0c8d6750e..a49a2d3fc8 100644 --- a/crates/nu-cli/src/shell/completer.rs +++ b/crates/nu-cli/src/shell/completer.rs @@ -63,7 +63,7 @@ impl NuCompleter { let partial = if let Some(quote_char) = quote_char { if partial.ends_with(quote_char) { - &partial[..partial.len()] + &partial[..partial.len() - 1] } else { partial } diff --git a/crates/nu-cli/src/shell/helper.rs b/crates/nu-cli/src/shell/helper.rs index 3c67149b1b..b17856a9da 100644 --- a/crates/nu-cli/src/shell/helper.rs +++ b/crates/nu-cli/src/shell/helper.rs @@ -52,6 +52,11 @@ impl rustyline::completion::Completer for Helper { let ctx = completion::Context::new(&self.context); Ok(self.completer.complete(line, pos, &ctx)) } + + fn update(&self, line: &mut rustyline::line_buffer::LineBuffer, start: usize, elected: &str) { + let end = (start + elected.len()).min(line.len()); + line.replace(start..end, elected) + } } impl rustyline::hint::Hinter for Helper {