chore: Remove outline dependency from breadcrumbs (#22504)
This slashes our incremental dev times (touch editor) by 0.6s (8.1->7.6s) due to unblocking terminal_view build sooner. Closes #ISSUE Release Notes: - N/A
This commit is contained in:
parent
5f4f3a9c87
commit
3f33ca01a8
9 changed files with 43 additions and 16 deletions
3
Cargo.lock
generated
3
Cargo.lock
generated
|
@ -1945,10 +1945,10 @@ dependencies = [
|
||||||
"editor",
|
"editor",
|
||||||
"gpui",
|
"gpui",
|
||||||
"itertools 0.13.0",
|
"itertools 0.13.0",
|
||||||
"outline",
|
|
||||||
"theme",
|
"theme",
|
||||||
"ui",
|
"ui",
|
||||||
"workspace",
|
"workspace",
|
||||||
|
"zed_actions",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -8629,6 +8629,7 @@ dependencies = [
|
||||||
"ui",
|
"ui",
|
||||||
"util",
|
"util",
|
||||||
"workspace",
|
"workspace",
|
||||||
|
"zed_actions",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
|
@ -16,10 +16,10 @@ doctest = false
|
||||||
editor.workspace = true
|
editor.workspace = true
|
||||||
gpui.workspace = true
|
gpui.workspace = true
|
||||||
itertools.workspace = true
|
itertools.workspace = true
|
||||||
outline.workspace = true
|
|
||||||
theme.workspace = true
|
theme.workspace = true
|
||||||
ui.workspace = true
|
ui.workspace = true
|
||||||
workspace.workspace = true
|
workspace.workspace = true
|
||||||
|
zed_actions.workspace = true
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
editor = { workspace = true, features = ["test-support"] }
|
editor = { workspace = true, features = ["test-support"] }
|
||||||
|
|
|
@ -102,8 +102,11 @@ impl Render for Breadcrumbs {
|
||||||
.on_click({
|
.on_click({
|
||||||
let editor = editor.clone();
|
let editor = editor.clone();
|
||||||
move |_, cx| {
|
move |_, cx| {
|
||||||
if let Some(editor) = editor.upgrade() {
|
if let Some((editor, callback)) = editor
|
||||||
outline::toggle(editor, &editor::actions::ToggleOutline, cx)
|
.upgrade()
|
||||||
|
.zip(zed_actions::outline::TOGGLE_OUTLINE.get())
|
||||||
|
{
|
||||||
|
callback(editor.to_any(), cx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -112,14 +115,14 @@ impl Render for Breadcrumbs {
|
||||||
let focus_handle = editor.read(cx).focus_handle(cx);
|
let focus_handle = editor.read(cx).focus_handle(cx);
|
||||||
Tooltip::for_action_in(
|
Tooltip::for_action_in(
|
||||||
"Show Symbol Outline",
|
"Show Symbol Outline",
|
||||||
&editor::actions::ToggleOutline,
|
&zed_actions::outline::ToggleOutline,
|
||||||
&focus_handle,
|
&focus_handle,
|
||||||
cx,
|
cx,
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
Tooltip::for_action(
|
Tooltip::for_action(
|
||||||
"Show Symbol Outline",
|
"Show Symbol Outline",
|
||||||
&editor::actions::ToggleOutline,
|
&zed_actions::outline::ToggleOutline,
|
||||||
cx,
|
cx,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -388,6 +388,4 @@ gpui::actions!(
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
action_as!(outline, ToggleOutline as Toggle);
|
|
||||||
|
|
||||||
action_as!(go_to_line, ToggleGoToLine as Toggle);
|
action_as!(go_to_line, ToggleGoToLine as Toggle);
|
||||||
|
|
|
@ -25,6 +25,7 @@ theme.workspace = true
|
||||||
ui.workspace = true
|
ui.workspace = true
|
||||||
util.workspace = true
|
util.workspace = true
|
||||||
workspace.workspace = true
|
workspace.workspace = true
|
||||||
|
zed_actions.workspace = true
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
editor = { workspace = true, features = ["test-support"] }
|
editor = { workspace = true, features = ["test-support"] }
|
||||||
|
|
|
@ -4,9 +4,7 @@ use std::{
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
};
|
};
|
||||||
|
|
||||||
use editor::{
|
use editor::{scroll::Autoscroll, Anchor, AnchorRangeExt, Editor, EditorMode};
|
||||||
actions::ToggleOutline, scroll::Autoscroll, Anchor, AnchorRangeExt, Editor, EditorMode,
|
|
||||||
};
|
|
||||||
use fuzzy::StringMatch;
|
use fuzzy::StringMatch;
|
||||||
use gpui::{
|
use gpui::{
|
||||||
div, rems, AppContext, DismissEvent, EventEmitter, FocusHandle, FocusableView, HighlightStyle,
|
div, rems, AppContext, DismissEvent, EventEmitter, FocusHandle, FocusableView, HighlightStyle,
|
||||||
|
@ -24,9 +22,22 @@ use workspace::{DismissDecision, ModalView};
|
||||||
|
|
||||||
pub fn init(cx: &mut AppContext) {
|
pub fn init(cx: &mut AppContext) {
|
||||||
cx.observe_new_views(OutlineView::register).detach();
|
cx.observe_new_views(OutlineView::register).detach();
|
||||||
|
zed_actions::outline::TOGGLE_OUTLINE
|
||||||
|
.set(|view, cx| {
|
||||||
|
let Ok(view) = view.downcast::<Editor>() else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
|
toggle(view, &Default::default(), cx);
|
||||||
|
})
|
||||||
|
.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn toggle(editor: View<Editor>, _: &ToggleOutline, cx: &mut WindowContext) {
|
pub fn toggle(
|
||||||
|
editor: View<Editor>,
|
||||||
|
_: &zed_actions::outline::ToggleOutline,
|
||||||
|
cx: &mut WindowContext,
|
||||||
|
) {
|
||||||
let outline = editor
|
let outline = editor
|
||||||
.read(cx)
|
.read(cx)
|
||||||
.buffer()
|
.buffer()
|
||||||
|
@ -459,7 +470,7 @@ mod tests {
|
||||||
workspace: &View<Workspace>,
|
workspace: &View<Workspace>,
|
||||||
cx: &mut VisualTestContext,
|
cx: &mut VisualTestContext,
|
||||||
) -> View<Picker<OutlineViewDelegate>> {
|
) -> View<Picker<OutlineViewDelegate>> {
|
||||||
cx.dispatch_action(ToggleOutline);
|
cx.dispatch_action(zed_actions::outline::ToggleOutline);
|
||||||
workspace.update(cx, |workspace, cx| {
|
workspace.update(cx, |workspace, cx| {
|
||||||
workspace
|
workspace
|
||||||
.active_modal::<OutlineView>(cx)
|
.active_modal::<OutlineView>(cx)
|
||||||
|
|
|
@ -156,7 +156,10 @@ pub fn app_menus() -> Vec<Menu> {
|
||||||
MenuItem::separator(),
|
MenuItem::separator(),
|
||||||
MenuItem::action("Go to File...", workspace::ToggleFileFinder::default()),
|
MenuItem::action("Go to File...", workspace::ToggleFileFinder::default()),
|
||||||
// MenuItem::action("Go to Symbol in Project", project_symbols::Toggle),
|
// MenuItem::action("Go to Symbol in Project", project_symbols::Toggle),
|
||||||
MenuItem::action("Go to Symbol in Editor...", editor::actions::ToggleOutline),
|
MenuItem::action(
|
||||||
|
"Go to Symbol in Editor...",
|
||||||
|
zed_actions::outline::ToggleOutline,
|
||||||
|
),
|
||||||
MenuItem::action("Go to Line/Column...", editor::actions::ToggleGoToLine),
|
MenuItem::action("Go to Line/Column...", editor::actions::ToggleGoToLine),
|
||||||
MenuItem::separator(),
|
MenuItem::separator(),
|
||||||
MenuItem::action("Go to Definition", editor::actions::GoToDefinition),
|
MenuItem::action("Go to Definition", editor::actions::GoToDefinition),
|
||||||
|
|
|
@ -6,7 +6,7 @@ use assistant::AssistantPanel;
|
||||||
use editor::actions::{
|
use editor::actions::{
|
||||||
AddSelectionAbove, AddSelectionBelow, DuplicateLineDown, GoToDiagnostic, GoToHunk,
|
AddSelectionAbove, AddSelectionBelow, DuplicateLineDown, GoToDiagnostic, GoToHunk,
|
||||||
GoToPrevDiagnostic, GoToPrevHunk, MoveLineDown, MoveLineUp, SelectAll, SelectLargerSyntaxNode,
|
GoToPrevDiagnostic, GoToPrevHunk, MoveLineDown, MoveLineUp, SelectAll, SelectLargerSyntaxNode,
|
||||||
SelectNext, SelectSmallerSyntaxNode, ToggleGoToLine, ToggleOutline,
|
SelectNext, SelectSmallerSyntaxNode, ToggleGoToLine,
|
||||||
};
|
};
|
||||||
use editor::{Editor, EditorSettings};
|
use editor::{Editor, EditorSettings};
|
||||||
use gpui::{
|
use gpui::{
|
||||||
|
@ -23,7 +23,7 @@ use vim_mode_setting::VimModeSetting;
|
||||||
use workspace::{
|
use workspace::{
|
||||||
item::ItemHandle, ToolbarItemEvent, ToolbarItemLocation, ToolbarItemView, Workspace,
|
item::ItemHandle, ToolbarItemEvent, ToolbarItemLocation, ToolbarItemView, Workspace,
|
||||||
};
|
};
|
||||||
use zed_actions::InlineAssist;
|
use zed_actions::{outline::ToggleOutline, InlineAssist};
|
||||||
|
|
||||||
pub struct QuickActionBar {
|
pub struct QuickActionBar {
|
||||||
_inlay_hints_enabled_subscription: Option<Subscription>,
|
_inlay_hints_enabled_subscription: Option<Subscription>,
|
||||||
|
|
|
@ -151,3 +151,13 @@ pub struct Rerun {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl_actions!(task, [Spawn, Rerun]);
|
impl_actions!(task, [Spawn, Rerun]);
|
||||||
|
|
||||||
|
pub mod outline {
|
||||||
|
use std::sync::OnceLock;
|
||||||
|
|
||||||
|
use gpui::{action_as, AnyView, WindowContext};
|
||||||
|
|
||||||
|
action_as!(outline, ToggleOutline as Toggle);
|
||||||
|
/// A pointer to outline::toggle function, exposed here to sewer the breadcrumbs <-> outline dependency.
|
||||||
|
pub static TOGGLE_OUTLINE: OnceLock<fn(AnyView, &mut WindowContext<'_>)> = OnceLock::new();
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue