Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixes
* fix commit dialog char count for multibyte characters ([#1726](https://github.com/extrawurst/gitui/issues/1726))
* fix wrong hit highlighting in fuzzy find popup [[@UUGTech](https://github.com/UUGTech)] ([#1731](https://github.com/extrawurst/gitui/pull/1731))

## [0.23.0] - 2022-06-19

Expand Down
58 changes: 33 additions & 25 deletions src/components/fuzzy_find_popup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use ratatui::{
Frame,
};
use std::borrow::Cow;
use unicode_segmentation::UnicodeSegmentation;

pub struct FuzzyFindPopup {
queue: Queue,
Expand Down Expand Up @@ -237,31 +238,38 @@ impl DrawableComponent for FuzzyFindPopup {
let height = usize::from(chunks[1].height);
let width = usize::from(chunks[1].width);

let items = self.filtered.iter().take(height).map(
|(idx, indicies)| {
let selected = self
.selected_index
.map_or(false, |index| index == *idx);
let full_text = trim_length_left(
&self.contents[*idx],
width,
);
Line::from(
full_text
.char_indices()
.map(|(c_idx, c)| {
Span::styled(
Cow::from(c.to_string()),
self.theme.text(
selected,
indicies.contains(&c_idx),
),
)
})
.collect::<Vec<_>>(),
)
},
);
let items =
self.filtered.iter().take(height).map(
|(idx, indicies)| {
let selected = self
.selected_index
.map_or(false, |index| index == *idx);
let full_text = trim_length_left(
&self.contents[*idx],
width,
);
let trim_length = self.contents[*idx]
.graphemes(true)
.count() - full_text
.graphemes(true)
.count();
Line::from(
full_text
.graphemes(true)
.enumerate()
.map(|(c_idx, c)| {
Span::styled(
Cow::from(c.to_string()),
self.theme.text(
selected,
indicies.contains(&(c_idx + trim_length)),
),
)
})
.collect::<Vec<_>>(),
)
},
);

ui::draw_list_block(
f,
Expand Down