Add a way to filter items in the outline panel (#13984)

https://github.com/zed-industries/zed/assets/2690773/145a7cf2-332c-46c9-ab2f-42a77504f54f

Adds a way to filter entries in the outline panel, by showing all
entries (even if their parents were collapsed) that fuzzy match a given
query.

Release Notes:

- Added a way to filter items in the outline panel
This commit is contained in:
Kirill Bulatov 2024-07-09 16:44:24 +03:00 committed by GitHub
parent 9a6f30fd95
commit 9b688655a8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 1072 additions and 870 deletions

View file

@ -5,7 +5,7 @@ use gpui::{
};
use settings::Settings;
use std::ops::Range;
use theme::{ActiveTheme, ThemeSettings};
use theme::{color_alpha, ActiveTheme, ThemeSettings};
/// An outline of all the symbols contained in a buffer.
#[derive(Debug)]
@ -146,9 +146,15 @@ impl<T> Outline<T> {
pub fn render_item<T>(
outline_item: &OutlineItem<T>,
custom_highlights: impl IntoIterator<Item = (Range<usize>, HighlightStyle)>,
match_ranges: impl IntoIterator<Item = Range<usize>>,
cx: &AppContext,
) -> StyledText {
let mut highlight_style = HighlightStyle::default();
highlight_style.background_color = Some(color_alpha(cx.theme().colors().text_accent, 0.3));
let custom_highlights = match_ranges
.into_iter()
.map(|range| (range, highlight_style));
let settings = ThemeSettings::get_global(cx);
// TODO: We probably shouldn't need to build a whole new text style here