mirror of
https://github.com/zed-industries/zed.git
synced 2025-02-05 10:20:51 +00:00
Create more specific dock position settings associated with each panel
This commit is contained in:
parent
e507eadb4b
commit
0ccb4a50e6
4 changed files with 44 additions and 38 deletions
|
@ -1347,12 +1347,15 @@ impl Entity for ProjectPanel {
|
||||||
impl workspace::dock::Panel for ProjectPanel {
|
impl workspace::dock::Panel for ProjectPanel {
|
||||||
fn position(&self, cx: &gpui::WindowContext) -> DockPosition {
|
fn position(&self, cx: &gpui::WindowContext) -> DockPosition {
|
||||||
let settings = cx.global::<Settings>();
|
let settings = cx.global::<Settings>();
|
||||||
settings
|
let dock = settings
|
||||||
.project_panel_overrides
|
.project_panel_overrides
|
||||||
.dock
|
.dock
|
||||||
.or(settings.project_panel_defaults.dock)
|
.or(settings.project_panel_defaults.dock)
|
||||||
.unwrap()
|
.unwrap();
|
||||||
.into()
|
match dock {
|
||||||
|
settings::ProjectPanelDockPosition::Left => DockPosition::Left,
|
||||||
|
settings::ProjectPanelDockPosition::Right => DockPosition::Right,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn position_is_valid(&self, position: DockPosition) -> bool {
|
fn position_is_valid(&self, position: DockPosition) -> bool {
|
||||||
|
@ -1361,7 +1364,13 @@ impl workspace::dock::Panel for ProjectPanel {
|
||||||
|
|
||||||
fn set_position(&mut self, position: DockPosition, cx: &mut ViewContext<Self>) {
|
fn set_position(&mut self, position: DockPosition, cx: &mut ViewContext<Self>) {
|
||||||
SettingsFile::update(cx, move |settings| {
|
SettingsFile::update(cx, move |settings| {
|
||||||
settings.project_panel.dock = Some(position.into())
|
let dock = match position {
|
||||||
|
DockPosition::Left | DockPosition::Bottom => {
|
||||||
|
settings::ProjectPanelDockPosition::Left
|
||||||
|
}
|
||||||
|
DockPosition::Right => settings::ProjectPanelDockPosition::Right,
|
||||||
|
};
|
||||||
|
settings.project_panel.dock = Some(dock);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -131,14 +131,6 @@ impl TelemetrySettings {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Serialize, Deserialize, JsonSchema, Eq, PartialEq)]
|
|
||||||
#[serde(rename_all = "lowercase")]
|
|
||||||
pub enum DockPosition {
|
|
||||||
Left,
|
|
||||||
Right,
|
|
||||||
Bottom,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default)]
|
#[derive(Clone, Debug, Default)]
|
||||||
pub struct CopilotSettings {
|
pub struct CopilotSettings {
|
||||||
pub disabled_globs: Vec<glob::Pattern>,
|
pub disabled_globs: Vec<glob::Pattern>,
|
||||||
|
@ -168,7 +160,14 @@ pub struct GitGutterConfig {}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Serialize, Deserialize, JsonSchema)]
|
#[derive(Clone, Debug, Default, Serialize, Deserialize, JsonSchema)]
|
||||||
pub struct ProjectPanelSettings {
|
pub struct ProjectPanelSettings {
|
||||||
pub dock: Option<DockPosition>,
|
pub dock: Option<ProjectPanelDockPosition>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema)]
|
||||||
|
#[serde(rename_all = "lowercase")]
|
||||||
|
pub enum ProjectPanelDockPosition {
|
||||||
|
Left,
|
||||||
|
Right,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Serialize, Deserialize, JsonSchema)]
|
#[derive(Clone, Debug, Default, Serialize, Deserialize, JsonSchema)]
|
||||||
|
@ -265,7 +264,15 @@ pub struct TerminalSettings {
|
||||||
pub alternate_scroll: Option<AlternateScroll>,
|
pub alternate_scroll: Option<AlternateScroll>,
|
||||||
pub option_as_meta: Option<bool>,
|
pub option_as_meta: Option<bool>,
|
||||||
pub copy_on_select: Option<bool>,
|
pub copy_on_select: Option<bool>,
|
||||||
pub dock: Option<DockPosition>,
|
pub dock: Option<TerminalDockPosition>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, JsonSchema)]
|
||||||
|
#[serde(rename_all = "lowercase")]
|
||||||
|
pub enum TerminalDockPosition {
|
||||||
|
Left,
|
||||||
|
Bottom,
|
||||||
|
Right,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, JsonSchema, Default)]
|
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, JsonSchema, Default)]
|
||||||
|
|
|
@ -4,7 +4,7 @@ use gpui::{
|
||||||
WeakViewHandle,
|
WeakViewHandle,
|
||||||
};
|
};
|
||||||
use project::Project;
|
use project::Project;
|
||||||
use settings::{settings_file::SettingsFile, Settings, WorkingDirectory};
|
use settings::{settings_file::SettingsFile, Settings, TerminalDockPosition, WorkingDirectory};
|
||||||
use util::ResultExt;
|
use util::ResultExt;
|
||||||
use workspace::{
|
use workspace::{
|
||||||
dock::{DockPosition, Panel},
|
dock::{DockPosition, Panel},
|
||||||
|
@ -151,12 +151,17 @@ impl View for TerminalPanel {
|
||||||
impl Panel for TerminalPanel {
|
impl Panel for TerminalPanel {
|
||||||
fn position(&self, cx: &gpui::WindowContext) -> DockPosition {
|
fn position(&self, cx: &gpui::WindowContext) -> DockPosition {
|
||||||
let settings = cx.global::<Settings>();
|
let settings = cx.global::<Settings>();
|
||||||
settings
|
let dock = settings
|
||||||
.terminal_overrides
|
.terminal_overrides
|
||||||
.dock
|
.dock
|
||||||
.or(settings.terminal_defaults.dock)
|
.or(settings.terminal_defaults.dock)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.into()
|
.into();
|
||||||
|
match dock {
|
||||||
|
settings::TerminalDockPosition::Left => DockPosition::Left,
|
||||||
|
settings::TerminalDockPosition::Bottom => DockPosition::Bottom,
|
||||||
|
settings::TerminalDockPosition::Right => DockPosition::Right,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn position_is_valid(&self, _: DockPosition) -> bool {
|
fn position_is_valid(&self, _: DockPosition) -> bool {
|
||||||
|
@ -165,7 +170,12 @@ impl Panel for TerminalPanel {
|
||||||
|
|
||||||
fn set_position(&mut self, position: DockPosition, cx: &mut ViewContext<Self>) {
|
fn set_position(&mut self, position: DockPosition, cx: &mut ViewContext<Self>) {
|
||||||
SettingsFile::update(cx, move |settings| {
|
SettingsFile::update(cx, move |settings| {
|
||||||
settings.terminal.dock = Some(position.into());
|
let dock = match position {
|
||||||
|
DockPosition::Left => TerminalDockPosition::Left,
|
||||||
|
DockPosition::Bottom => TerminalDockPosition::Bottom,
|
||||||
|
DockPosition::Right => TerminalDockPosition::Right,
|
||||||
|
};
|
||||||
|
settings.terminal.dock = Some(dock);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -95,26 +95,6 @@ pub enum DockPosition {
|
||||||
Right,
|
Right,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<settings::DockPosition> for DockPosition {
|
|
||||||
fn from(value: settings::DockPosition) -> Self {
|
|
||||||
match value {
|
|
||||||
settings::DockPosition::Left => Self::Left,
|
|
||||||
settings::DockPosition::Bottom => Self::Bottom,
|
|
||||||
settings::DockPosition::Right => Self::Right,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<DockPosition> for settings::DockPosition {
|
|
||||||
fn from(value: DockPosition) -> settings::DockPosition {
|
|
||||||
match value {
|
|
||||||
DockPosition::Left => settings::DockPosition::Left,
|
|
||||||
DockPosition::Bottom => settings::DockPosition::Bottom,
|
|
||||||
DockPosition::Right => settings::DockPosition::Right,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl DockPosition {
|
impl DockPosition {
|
||||||
fn to_label(&self) -> &'static str {
|
fn to_label(&self) -> &'static str {
|
||||||
match self {
|
match self {
|
||||||
|
|
Loading…
Reference in a new issue