Reduce amount of workspace serialization happening (#22730)
Part of https://github.com/zed-industries/zed/issues/16472 Reduces amount of workspace serialization happening by: * fixing the deserialization logic: now it does not set panels that are hidden to active * cleaning up `active_panel_index` for docks that are closed, to avoid emitting extra events for such closed docks * adjusting outline panel to drop active editor subscriptions on deactivation — this way, `cx.observe` on the dock with outline panel is not triggered (used to be triggered on every selection change before) * adjusting workspace dock drag listener to remember previous coordinates and only resize the dock if those had changed * adjusting workspace pane event listener to ignore `pane::Event::UserSavedItem` and `pane::Event::ChangeItemTitle` that seem to happen relatively frequently but not influence values that are serialized for the workspace * not using `cx.observe` on docks, instead explicitly serializing on panel zoom and size changes Release Notes: - Reduced amount of workspace serialization happening
This commit is contained in:
parent
4c47728d6f
commit
a827f54022
3 changed files with 101 additions and 66 deletions
|
@ -4656,18 +4656,27 @@ impl Panel for OutlinePanel {
|
|||
.update(&mut cx, |outline_panel, cx| {
|
||||
let old_active = outline_panel.active;
|
||||
outline_panel.active = active;
|
||||
if active && old_active != active {
|
||||
if let Some((active_item, active_editor)) = outline_panel
|
||||
.workspace
|
||||
.upgrade()
|
||||
.and_then(|workspace| workspace_active_editor(workspace.read(cx), cx))
|
||||
{
|
||||
if outline_panel.should_replace_active_item(active_item.as_ref()) {
|
||||
outline_panel.replace_active_editor(active_item, active_editor, cx);
|
||||
} else {
|
||||
outline_panel.update_fs_entries(active_editor, None, cx)
|
||||
if old_active != active {
|
||||
if active {
|
||||
if let Some((active_item, active_editor)) =
|
||||
outline_panel.workspace.upgrade().and_then(|workspace| {
|
||||
workspace_active_editor(workspace.read(cx), cx)
|
||||
})
|
||||
{
|
||||
if outline_panel.should_replace_active_item(active_item.as_ref()) {
|
||||
outline_panel.replace_active_editor(
|
||||
active_item,
|
||||
active_editor,
|
||||
cx,
|
||||
);
|
||||
} else {
|
||||
outline_panel.update_fs_entries(active_editor, None, cx)
|
||||
}
|
||||
return;
|
||||
}
|
||||
} else if !outline_panel.pinned {
|
||||
}
|
||||
|
||||
if !outline_panel.pinned {
|
||||
outline_panel.clear_previous(cx);
|
||||
}
|
||||
}
|
||||
|
@ -4814,9 +4823,11 @@ fn subscribe_for_editor_events(
|
|||
cx: &mut ViewContext<OutlinePanel>,
|
||||
) -> Subscription {
|
||||
let debounce = Some(UPDATE_DEBOUNCE);
|
||||
cx.subscribe(
|
||||
editor,
|
||||
move |outline_panel, editor, e: &EditorEvent, cx| match e {
|
||||
cx.subscribe(editor, move |outline_panel, editor, e: &EditorEvent, cx| {
|
||||
if !outline_panel.active {
|
||||
return;
|
||||
}
|
||||
match e {
|
||||
EditorEvent::SelectionsChanged { local: true } => {
|
||||
outline_panel.reveal_entry_for_selection(editor, cx);
|
||||
cx.notify();
|
||||
|
@ -4921,8 +4932,8 @@ fn subscribe_for_editor_events(
|
|||
outline_panel.update_non_fs_items(cx);
|
||||
}
|
||||
_ => {}
|
||||
},
|
||||
)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fn empty_icon() -> AnyElement {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue