stabilize ids and harden release pipeline
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
use std::cell::Cell;
|
||||
use std::collections::HashMap;
|
||||
use std::rc::Rc;
|
||||
use std::sync::Arc;
|
||||
|
||||
@@ -17,7 +18,7 @@ use gpui_kit::component::button::Button;
|
||||
use gpui_kit::component::command::{
|
||||
Command as CommandPalette, CommandGroup, CommandItem, CommandState,
|
||||
};
|
||||
use gpui_kit::component::dock::{DockArea, DockLayout, DockPlacement, Panel, PanelHandle};
|
||||
use gpui_kit::component::dock::{DockArea, DockLayout, DockPlacement, Panel, PanelHandle, PanelId};
|
||||
use gpui_kit::component::notification::{Notification, NotificationType};
|
||||
use gpui_kit::component::{
|
||||
ActiveTheme, IndexPath, Theme, ThemeConfig, ThemeRegistry, WindowExt, v_flex,
|
||||
@@ -80,6 +81,9 @@ enum Command {
|
||||
pub struct Workspace {
|
||||
dock: Entity<DockArea>,
|
||||
sidebar: Entity<Sidebar>,
|
||||
/// Group panels docked by group key, so reopening a group focuses its panel.
|
||||
/// Group panels hide their group, so the dock cannot tell them apart.
|
||||
group_panels: HashMap<GroupKey, PanelId>,
|
||||
/// Async tasks
|
||||
tasks: Vec<Task<Result<(), Error>>>,
|
||||
/// Event subscriptions
|
||||
@@ -285,6 +289,7 @@ impl Workspace {
|
||||
Self {
|
||||
dock,
|
||||
sidebar,
|
||||
group_panels: HashMap::new(),
|
||||
tasks: vec![],
|
||||
_subscriptions: subscriptions,
|
||||
}
|
||||
@@ -319,6 +324,43 @@ impl Workspace {
|
||||
});
|
||||
}
|
||||
|
||||
fn add_group_panel_to_dock(
|
||||
&mut self,
|
||||
group_key: GroupKey,
|
||||
panel: PanelHandle,
|
||||
placement: DockPlacement,
|
||||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
let panel_id = panel.panel_id(cx);
|
||||
let docked = self.group_panels.get(&group_key).copied();
|
||||
|
||||
let mut added = false;
|
||||
let mut focused = false;
|
||||
|
||||
self.dock.update(cx, |area, cx| {
|
||||
if let Some(id) = docked
|
||||
&& area.panel(id).is_some()
|
||||
{
|
||||
crate::dock::focus_panel(area, id, window, cx);
|
||||
focused = true;
|
||||
return;
|
||||
}
|
||||
crate::dock::add_panel(area, panel, placement, window, cx);
|
||||
added = area.panel(panel_id).is_some();
|
||||
});
|
||||
|
||||
if focused {
|
||||
return;
|
||||
}
|
||||
|
||||
if added {
|
||||
self.group_panels.insert(group_key, panel_id);
|
||||
} else {
|
||||
self.group_panels.remove(&group_key);
|
||||
}
|
||||
}
|
||||
|
||||
/// Handle command events
|
||||
fn on_command(&mut self, command: &Command, window: &mut Window, cx: &mut Context<Self>) {
|
||||
match command {
|
||||
|
||||
Reference in New Issue
Block a user