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

@ -3,9 +3,8 @@ use editor::{
};
use fuzzy::StringMatch;
use gpui::{
div, rems, AppContext, DismissEvent, EventEmitter, FocusHandle, FocusableView, HighlightStyle,
ParentElement, Point, Render, Styled, Task, View, ViewContext, VisualContext, WeakView,
WindowContext,
div, rems, AppContext, DismissEvent, EventEmitter, FocusHandle, FocusableView, ParentElement,
Point, Render, Styled, Task, View, ViewContext, VisualContext, WeakView, WindowContext,
};
use language::Outline;
use ordered_float::OrderedFloat;
@ -15,7 +14,7 @@ use std::{
sync::Arc,
};
use theme::{color_alpha, ActiveTheme};
use theme::ActiveTheme;
use ui::{prelude::*, ListItem, ListItemSpacing};
use util::ResultExt;
use workspace::{DismissDecision, ModalView};
@ -272,10 +271,6 @@ impl PickerDelegate for OutlineViewDelegate {
let mat = self.matches.get(ix)?;
let outline_item = self.outline.items.get(mat.candidate_id)?;
let mut highlight_style = HighlightStyle::default();
highlight_style.background_color = Some(color_alpha(cx.theme().colors().text_accent, 0.3));
let custom_highlights = mat.ranges().map(|range| (range, highlight_style));
Some(
ListItem::new(ix)
.inset(true)
@ -285,7 +280,7 @@ impl PickerDelegate for OutlineViewDelegate {
div()
.text_ui(cx)
.pl(rems(outline_item.depth as f32))
.child(language::render_item(outline_item, custom_highlights, cx)),
.child(language::render_item(outline_item, mat.ranges(), cx)),
),
)
}