mirror of
https://github.com/nushell/nushell.git
synced 2024-11-26 02:13:47 +01:00
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:
parent
60ce497edc
commit
b5d591bb09
@ -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
|
||||
}
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user