Improve support for completing within quotes. (#2474)

We ensure the partially cimpleted item doesn't include the end quote. We also
ensure that the appropriate span is replaced, not just the suggested position up
to the cursor position.
This commit is contained in:
Jason Gedge 2020-08-31 22:13:00 -04:00 committed by GitHub
parent 60ce497edc
commit b5d591bb09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View File

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

View File

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