Skip to content
Open
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
25 changes: 21 additions & 4 deletions src/app/screens/mail_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,32 @@ impl MailingListSelection {
}

fn process_possible_mailing_lists(&mut self) {
let mut possible_mailing_lists: Vec<MailingList> = Vec::new();
if self.target_list.is_empty() {
self.possible_mailing_lists = self.mailing_lists.clone();
self.highlighted_list_index = 0;
return;
}

let query = self.target_list.to_lowercase();
let mut exact_matches: Vec<MailingList> = Vec::new();
let mut partial_matches: Vec<MailingList> = Vec::new();

for mailing_list in &self.mailing_lists {
if mailing_list.name().starts_with(&self.target_list) {
possible_mailing_lists.push(mailing_list.clone());
let name_lower = mailing_list.name().to_lowercase();
let desc_lower = mailing_list.description().to_lowercase();

// Check for exact match first (case-insensitive)
if name_lower == query {
exact_matches.push(mailing_list.clone());
} else if name_lower.contains(&query) || desc_lower.contains(&query) {
partial_matches.push(mailing_list.clone());
}
}

self.possible_mailing_lists = possible_mailing_lists;
// Prioritize exact matches by placing them first
let mut all_matches = exact_matches;
all_matches.append(&mut partial_matches);
self.possible_mailing_lists = all_matches;
self.highlighted_list_index = 0;
}

Expand Down
4 changes: 2 additions & 2 deletions src/ui/edit_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ pub fn render_main(f: &mut Frame, app: &App, chunk: Rect) {
}
}

pub fn mode_footer_text(app: &App) -> Vec<Span> {
pub fn mode_footer_text(app: &App) -> Vec<Span<'_>> {
let edit_config_state = app.edit_config.as_ref().unwrap();
vec![if edit_config_state.is_editing() {
Span::styled("Editing...", Style::default().fg(Color::LightYellow))
Expand All @@ -73,7 +73,7 @@ pub fn mode_footer_text(app: &App) -> Vec<Span> {
}]
}

pub fn keys_hint(app: &App) -> Span {
pub fn keys_hint(app: &App) -> Span<'_> {
let edit_config_state = app.edit_config.as_ref().unwrap();
match edit_config_state.is_editing() {
true => Span::styled(
Expand Down
2 changes: 1 addition & 1 deletion src/ui/latest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ pub fn render_main(f: &mut Frame, app: &App, chunk: Rect) {
f.render_stateful_widget(list, chunk, &mut list_state);
}

pub fn mode_footer_text(app: &App) -> Vec<Span> {
pub fn mode_footer_text(app: &App) -> Vec<Span<'_>> {
vec![Span::styled(
format!(
"Latest Patchsets from {} (page {})",
Expand Down
51 changes: 22 additions & 29 deletions src/ui/mail_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,39 +50,32 @@ pub fn render_main(f: &mut Frame, app: &App, chunk: Rect) {
f.render_stateful_widget(list, chunk, &mut list_state);
}

pub fn mode_footer_text(app: &App) -> Vec<Span> {
let mut text_area = Span::default();

if app.mailing_list_selection.target_list.is_empty() {
text_area = Span::styled("type the target list", Style::default().fg(Color::DarkGray))
pub fn mode_footer_text(app: &App) -> Vec<Span<'_>> {
let text_area = if app.mailing_list_selection.target_list.is_empty() {
Span::styled("type the target list", Style::default().fg(Color::DarkGray))
} else {
for mailing_list in &app.mailing_list_selection.mailing_lists {
if mailing_list
.name()
.eq(&app.mailing_list_selection.target_list)
{
text_area = Span::styled(
&app.mailing_list_selection.target_list,
Style::default().fg(Color::Green),
);
break;
} else if mailing_list
.name()
.starts_with(&app.mailing_list_selection.target_list)
{
text_area = Span::styled(
&app.mailing_list_selection.target_list,
Style::default().fg(Color::LightCyan),
);
}
}
if text_area.content.is_empty() {
text_area = Span::styled(
let exact_match = app.mailing_list_selection.mailing_lists.iter().any(|ml| {
ml.name()
.eq_ignore_ascii_case(&app.mailing_list_selection.target_list)
});

if exact_match {
Span::styled(
&app.mailing_list_selection.target_list,
Style::default().fg(Color::Green),
)
} else if !app.mailing_list_selection.possible_mailing_lists.is_empty() {
Span::styled(
&app.mailing_list_selection.target_list,
Style::default().fg(Color::LightCyan),
)
} else {
Span::styled(
&app.mailing_list_selection.target_list,
Style::default().fg(Color::Red),
);
)
}
}
};

vec![
Span::styled("Target List: ", Style::default().fg(Color::Green)),
Expand Down