Revert tab completion changes (#2929)

* Undo tab completion changes

* Remove extra newline
This commit is contained in:
Coen Fox 2021-01-14 04:29:18 +11:00 committed by GitHub
parent 495d2ebd70
commit a9441d670e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -51,27 +51,7 @@ impl rustyline::completion::Completer for Helper {
}
fn update(&self, line: &mut rustyline::line_buffer::LineBuffer, start: usize, elected: &str) {
let end = start
+ match line
.as_str()
.chars()
.into_iter()
.skip(start)
.zip(elected.chars().into_iter())
.enumerate()
.find(|(_, (line, replace))| line != replace)
{
Some((index, (_, _))) => index,
None => line.pos(),
};
let mut end = end.max(line.pos());
let remaining = &line.as_str()[end..];
if remaining.starts_with('"') {
end += 1;
}
let end = line.pos();
line.replace(start..end, elected)
}
}
@ -172,6 +152,7 @@ mod tests {
use rustyline::completion::Completer;
use rustyline::line_buffer::LineBuffer;
#[ignore]
#[test]
fn closing_quote_should_replaced() {
let text = "cd \"folder with spaces\\subdirectory\\\"";
@ -191,6 +172,7 @@ mod tests {
);
}
#[ignore]
#[test]
fn replacement_with_cursor_in_text() {
let text = "cd \"folder with spaces\\subdirectory\\\"";