From 3911d3b26792668c8d403a04465c9f5ca7f673cd Mon Sep 17 00:00:00 2001 From: cameron Date: Fri, 6 Mar 2026 17:12:45 +0000 Subject: [PATCH] make search include child threads --- crates/sidebar/src/sidebar.rs | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/crates/sidebar/src/sidebar.rs b/crates/sidebar/src/sidebar.rs index 3bb3ea9ea44efe2cf57a4d021b0a1755ac3b3681..20496606274511ff9b0315cafa1b24f85a667e23 100644 --- a/crates/sidebar/src/sidebar.rs +++ b/crates/sidebar/src/sidebar.rs @@ -522,6 +522,10 @@ impl Sidebar { } if !query.is_empty() { + let workspace_highlight_positions = + fuzzy_match_positions(&query, &label).unwrap_or_default(); + let workspace_matches = !workspace_highlight_positions.is_empty(); + let mut matched_threads = Vec::new(); for mut thread in threads { if let ListEntry::Thread { @@ -537,15 +541,14 @@ impl Sidebar { .unwrap_or(""); if let Some(positions) = fuzzy_match_positions(&query, title) { *highlight_positions = positions; + } + if !highlight_positions.is_empty() || workspace_matches { matched_threads.push(thread); } } } - let workspace_highlight_positions = - fuzzy_match_positions(&query, &label).unwrap_or_default(); - - if matched_threads.is_empty() && workspace_highlight_positions.is_empty() { + if matched_threads.is_empty() && !workspace_matches { continue; } @@ -2791,11 +2794,15 @@ mod tests { cx.run_until_parked(); // "alpha" matches the workspace name "alpha-project" but no thread titles. - // The workspace header should appear with no child threads. + // The workspace header should appear with all its child threads. type_in_search(&sidebar, "alpha", cx); assert_eq!( visible_entries_as_strings(&sidebar, cx), - vec!["v [alpha-project] <== selected"] + vec![ + "v [alpha-project] <== selected", + " Fix bug in sidebar", + " Add tests for editor", + ] ); // "sidebar" matches thread titles in both workspaces but not workspace names. @@ -2827,11 +2834,15 @@ mod tests { ); // A query that matches a workspace name AND a thread in that same workspace. - // Both the header (highlighted) and the matching thread should appear. + // Both the header (highlighted) and all child threads should appear. type_in_search(&sidebar, "alpha", cx); assert_eq!( visible_entries_as_strings(&sidebar, cx), - vec!["v [alpha-project] <== selected"] + vec![ + "v [alpha-project] <== selected", + " Fix bug in sidebar", + " Add tests for editor", + ] ); // Now search for something that matches only a workspace name when there @@ -2840,7 +2851,11 @@ mod tests { type_in_search(&sidebar, "alp", cx); assert_eq!( visible_entries_as_strings(&sidebar, cx), - vec!["v [alpha-project] <== selected"] + vec![ + "v [alpha-project] <== selected", + " Fix bug in sidebar", + " Add tests for editor", + ] ); }