Activate the correct panel when deserializing workspace
This commit is contained in:
parent
f2ad17dbc0
commit
3d6b728364
2 changed files with 29 additions and 8 deletions
|
@ -1,8 +1,9 @@
|
|||
use crate::{StatusItemView, Workspace};
|
||||
use context_menu::{ContextMenu, ContextMenuItem};
|
||||
use gpui::{
|
||||
elements::*, impl_actions, platform::CursorStyle, platform::MouseButton, AnyViewHandle, Axis,
|
||||
Entity, Subscription, View, ViewContext, ViewHandle, WeakViewHandle, WindowContext,
|
||||
elements::*, impl_actions, platform::CursorStyle, platform::MouseButton, AnyViewHandle,
|
||||
AppContext, Axis, Entity, Subscription, View, ViewContext, ViewHandle, WeakViewHandle,
|
||||
WindowContext,
|
||||
};
|
||||
use serde::Deserialize;
|
||||
use settings::Settings;
|
||||
|
@ -181,12 +182,19 @@ impl Dock {
|
|||
.map_or(false, |panel| panel.has_focus(cx))
|
||||
}
|
||||
|
||||
pub fn panel_index<T: Panel>(&self) -> Option<usize> {
|
||||
pub fn panel_index_for_type<T: Panel>(&self) -> Option<usize> {
|
||||
self.panel_entries
|
||||
.iter()
|
||||
.position(|entry| entry.panel.as_any().is::<T>())
|
||||
}
|
||||
|
||||
pub fn panel_index_for_ui_name(&self, ui_name: &str, cx: &AppContext) -> Option<usize> {
|
||||
self.panel_entries.iter().position(|entry| {
|
||||
let panel = entry.panel.as_any();
|
||||
cx.view_ui_name(panel.window_id(), panel.id()) == Some(ui_name)
|
||||
})
|
||||
}
|
||||
|
||||
pub fn active_panel_index(&self) -> usize {
|
||||
self.active_panel_index
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue