mirror of
https://github.com/nushell/reedline.git
synced 2024-09-11 15:55:50 +03:00
can complete case insensitive (#340)
This commit is contained in:
parent
5cd2fa2655
commit
e1767338eb
@ -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
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user