mirror of
https://github.com/zed-industries/zed.git
synced 2024-11-28 09:54:33 +00:00
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:
parent
9a6f30fd95
commit
9b688655a8
7 changed files with 1072 additions and 870 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -7355,6 +7355,7 @@ dependencies = [
|
|||
"db",
|
||||
"editor",
|
||||
"file_icons",
|
||||
"fuzzy",
|
||||
"gpui",
|
||||
"itertools 0.11.0",
|
||||
"language",
|
||||
|
|
|
@ -502,6 +502,7 @@
|
|||
{
|
||||
"context": "OutlinePanel",
|
||||
"bindings": {
|
||||
"escape": "menu::Cancel",
|
||||
"left": "outline_panel::CollapseSelectedEntry",
|
||||
"right": "outline_panel::ExpandSelectedEntry",
|
||||
"ctrl-alt-c": "outline_panel::CopyPath",
|
||||
|
|
|
@ -523,6 +523,7 @@
|
|||
{
|
||||
"context": "OutlinePanel",
|
||||
"bindings": {
|
||||
"escape": "menu::Cancel",
|
||||
"left": "outline_panel::CollapseSelectedEntry",
|
||||
"right": "outline_panel::ExpandSelectedEntry",
|
||||
"cmd-alt-c": "outline_panel::CopyPath",
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ collections.workspace = true
|
|||
db.workspace = true
|
||||
editor.workspace = true
|
||||
file_icons.workspace = true
|
||||
fuzzy.workspace = true
|
||||
itertools.workspace = true
|
||||
gpui.workspace = true
|
||||
language.workspace = true
|
||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue