Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Change the default panel layout (#52232)

Mikayla Maki78df135d15b9
diff --git a/crates/agent_ui/src/agent_panel.rs b/crates/agent_ui/src/agent_panel.rs
index 73bde350fa1..ae7ab9d2cfb 100644
--- a/crates/agent_ui/src/agent_panel.rs
+++ b/crates/agent_ui/src/agent_panel.rs
@@ -3206,7 +3206,7 @@ impl Panel for AgentPanel {
}
fn activation_priority(&self) -> u32 {
- 3
+ 8
}
fn enabled(&self, cx: &App) -> bool {
diff --git a/crates/agent_ui/src/agent_ui.rs b/crates/agent_ui/src/agent_ui.rs
index db3b2526e45..8f41944723e 100644
--- a/crates/agent_ui/src/agent_ui.rs
+++ b/crates/agent_ui/src/agent_ui.rs
@@ -47,7 +47,7 @@ use client::Client;
use command_palette_hooks::CommandPaletteFilter;
use feature_flags::{AgentV2FeatureFlag, FeatureFlagAppExt as _};
use fs::Fs;
-use gpui::{Action, App, Context, Entity, SharedString, Window, actions};
+use gpui::{Action, App, Context, Entity, SharedString, UpdateGlobal, Window, actions};
use language::{
LanguageRegistry,
language_settings::{AllLanguageSettings, EditPredictionProvider},
@@ -59,7 +59,7 @@ use project::{AgentId, DisableAiSettings};
use prompt_store::PromptBuilder;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
-use settings::{LanguageModelSelection, Settings as _, SettingsStore};
+use settings::{DockPosition, DockSide, LanguageModelSelection, Settings as _, SettingsStore};
use std::any::TypeId;
use workspace::Workspace;
@@ -415,6 +415,31 @@ pub fn init(
update_command_palette_filter(cx);
})
.detach();
+
+ cx.observe_flag::<AgentV2FeatureFlag, _>(|is_enabled, cx| {
+ SettingsStore::update_global(cx, |store, cx| {
+ store.update_default_settings(cx, |defaults| {
+ if is_enabled {
+ defaults.agent.get_or_insert_default().dock = Some(DockPosition::Left);
+ defaults.project_panel.get_or_insert_default().dock = Some(DockSide::Right);
+ defaults.outline_panel.get_or_insert_default().dock = Some(DockSide::Right);
+ defaults.collaboration_panel.get_or_insert_default().dock =
+ Some(DockPosition::Right);
+ defaults.git_panel.get_or_insert_default().dock = Some(DockPosition::Right);
+ defaults.notification_panel.get_or_insert_default().button = Some(false);
+ } else {
+ defaults.agent.get_or_insert_default().dock = Some(DockPosition::Right);
+ defaults.project_panel.get_or_insert_default().dock = Some(DockSide::Left);
+ defaults.outline_panel.get_or_insert_default().dock = Some(DockSide::Left);
+ defaults.collaboration_panel.get_or_insert_default().dock =
+ Some(DockPosition::Left);
+ defaults.git_panel.get_or_insert_default().dock = Some(DockPosition::Left);
+ defaults.notification_panel.get_or_insert_default().button = Some(true);
+ }
+ });
+ });
+ })
+ .detach();
}
fn update_command_palette_filter(cx: &mut App) {
diff --git a/crates/collab_ui/src/collab_panel.rs b/crates/collab_ui/src/collab_panel.rs
index 34595e9440f..63fe636dab3 100644
--- a/crates/collab_ui/src/collab_panel.rs
+++ b/crates/collab_ui/src/collab_panel.rs
@@ -3229,7 +3229,7 @@ impl Panel for CollabPanel {
}
fn activation_priority(&self) -> u32 {
- 6
+ 5
}
}
diff --git a/crates/collab_ui/src/notification_panel.rs b/crates/collab_ui/src/notification_panel.rs
index 4374349b15f..be11132ac0a 100644
--- a/crates/collab_ui/src/notification_panel.rs
+++ b/crates/collab_ui/src/notification_panel.rs
@@ -690,7 +690,7 @@ impl Panel for NotificationPanel {
}
fn activation_priority(&self) -> u32 {
- 8
+ 3
}
}
diff --git a/crates/outline_panel/src/outline_panel.rs b/crates/outline_panel/src/outline_panel.rs
index c4d491db923..cad070392c5 100644
--- a/crates/outline_panel/src/outline_panel.rs
+++ b/crates/outline_panel/src/outline_panel.rs
@@ -5069,7 +5069,7 @@ impl Panel for OutlinePanel {
}
fn activation_priority(&self) -> u32 {
- 5
+ 6
}
}
diff --git a/crates/settings/src/settings_store.rs b/crates/settings/src/settings_store.rs
index 26425faf113..cc5a9105d69 100644
--- a/crates/settings/src/settings_store.rs
+++ b/crates/settings/src/settings_store.rs
@@ -793,6 +793,17 @@ impl SettingsStore {
edits
}
+ /// Mutates the default settings in place and recomputes all setting values.
+ pub fn update_default_settings(
+ &mut self,
+ cx: &mut App,
+ update: impl FnOnce(&mut SettingsContent),
+ ) {
+ let default_settings = Rc::make_mut(&mut self.default_settings);
+ update(default_settings);
+ self.recompute_values(None, cx);
+ }
+
/// Sets the default settings via a JSON string.
///
/// The string should contain a JSON object with a default value for every setting.
diff --git a/crates/workspace/src/dock.rs b/crates/workspace/src/dock.rs
index 44a24f687a4..1774539559c 100644
--- a/crates/workspace/src/dock.rs
+++ b/crates/workspace/src/dock.rs
@@ -911,7 +911,7 @@ impl Render for PanelButtons {
DockPosition::Bottom | DockPosition::Right => (Corner::BottomRight, Corner::TopRight),
};
- let buttons: Vec<_> = dock
+ let mut buttons: Vec<_> = dock
.panel_entries
.iter()
.enumerate()
@@ -1004,12 +1004,18 @@ impl Render for PanelButtons {
})
.collect();
+ if dock_position == DockPosition::Right {
+ buttons.reverse();
+ }
+
let has_buttons = !buttons.is_empty();
h_flex()
.gap_1()
.when(
- has_buttons && dock.position == DockPosition::Bottom,
+ has_buttons
+ && (dock.position == DockPosition::Bottom
+ || dock.position == DockPosition::Right),
|this| this.child(Divider::vertical().color(DividerColor::Border)),
)
.children(buttons)
diff --git a/crates/zed/src/zed.rs b/crates/zed/src/zed.rs
index 10d8c0d5974..3d933e35c68 100644
--- a/crates/zed/src/zed.rs
+++ b/crates/zed/src/zed.rs
@@ -2461,7 +2461,7 @@ mod tests {
.update(cx, |multi_workspace, window, cx| {
multi_workspace.workspace().update(cx, |workspace, cx| {
assert_eq!(workspace.worktrees(cx).count(), 2);
- assert!(workspace.left_dock().read(cx).is_open());
+ assert!(workspace.right_dock().read(cx).is_open());
assert!(
workspace
.active_pane()
@@ -2520,7 +2520,7 @@ mod tests {
.collect::<Vec<_>>(),
&[Path::new(path!("/root/e")).into()]
);
- assert!(workspace.left_dock().read(cx).is_open());
+ assert!(workspace.right_dock().read(cx).is_open());
assert!(workspace.active_pane().focus_handle(cx).is_focused(window));
})
.unwrap();