can complete case insensitive (#340)

This commit is contained in:
Fernando Herrera 2022-03-08 08:03:27 +00:00 committed by GitHub
parent 5cd2fa2655
commit e1767338eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 3 deletions

View File

@ -367,8 +367,14 @@ impl Menu for CompletionMenu {
if !matching.is_empty() {
line_buffer.replace(span.start..span.end, matching);
let mut offset = line_buffer.offset();
offset += matching.len() - (span.end - span.start);
let offset = if matching.len() < (span.end - span.start) {
line_buffer
.offset()
.saturating_sub((span.end - span.start) - matching.len())
} else {
line_buffer.offset() + matching.len() - (span.end - span.start)
};
line_buffer.set_insertion_point(offset);
// The values need to be updated because the spans need to be

View File

@ -188,7 +188,12 @@ fn find_common_string(values: &[(Span, String)]) -> (Option<&(Span, String)>, Op
first_string
.chars()
.zip(value.chars())
.position(|(lhs, rhs)| lhs != rhs)
.position(|(mut lhs, mut rhs)| {
lhs.make_ascii_lowercase();
rhs.make_ascii_lowercase();
lhs != rhs
})
.map(|new_index| match index {
Some(index) => {
if index <= new_index {