mirror of
https://github.com/zed-industries/zed.git
synced 2025-02-05 10:20:51 +00:00
Fix panic when not specifying a project_panel
setting
This commit is contained in:
parent
9173916ab8
commit
6e3ce6332a
2 changed files with 26 additions and 30 deletions
|
@ -150,7 +150,8 @@ impl ProjectPanel {
|
||||||
old_dock_position = new_dock_position;
|
old_dock_position = new_dock_position;
|
||||||
cx.emit(Event::DockPositionChanged);
|
cx.emit(Event::DockPositionChanged);
|
||||||
}
|
}
|
||||||
}).detach();
|
})
|
||||||
|
.detach();
|
||||||
|
|
||||||
cx.observe(&project, |this, _, cx| {
|
cx.observe(&project, |this, _, cx| {
|
||||||
this.update_visible_entries(None, cx);
|
this.update_visible_entries(None, cx);
|
||||||
|
@ -253,8 +254,8 @@ impl ProjectPanel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
Event::DockPositionChanged => {},
|
Event::DockPositionChanged => {}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.detach();
|
.detach();
|
||||||
|
@ -1341,7 +1342,11 @@ 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 {
|
||||||
cx.global::<Settings>().project_panel_overrides.dock.into()
|
cx.global::<Settings>()
|
||||||
|
.project_panel_overrides
|
||||||
|
.dock
|
||||||
|
.map(Into::into)
|
||||||
|
.unwrap_or(DockPosition::Left)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn position_is_valid(&self, position: DockPosition) -> bool {
|
fn position_is_valid(&self, position: DockPosition) -> bool {
|
||||||
|
|
|
@ -132,7 +132,7 @@ impl TelemetrySettings {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Serialize, Deserialize, JsonSchema, Eq, PartialEq)]
|
#[derive(Clone, Copy, Debug, Serialize, Deserialize, JsonSchema, Eq, PartialEq)]
|
||||||
#[serde(rename_all="lowercase")]
|
#[serde(rename_all = "lowercase")]
|
||||||
pub enum DockPosition {
|
pub enum DockPosition {
|
||||||
Left,
|
Left,
|
||||||
Right,
|
Right,
|
||||||
|
@ -166,17 +166,9 @@ pub enum GitGutter {
|
||||||
|
|
||||||
pub struct GitGutterConfig {}
|
pub struct GitGutterConfig {}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)]
|
#[derive(Clone, Debug, Default, Serialize, Deserialize, JsonSchema)]
|
||||||
pub struct ProjectPanelSettings {
|
pub struct ProjectPanelSettings {
|
||||||
pub dock: DockPosition
|
pub dock: Option<DockPosition>,
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for ProjectPanelSettings {
|
|
||||||
fn default() -> Self {
|
|
||||||
Self {
|
|
||||||
dock: DockPosition::Left
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Serialize, Deserialize, JsonSchema)]
|
#[derive(Clone, Debug, Default, Serialize, Deserialize, JsonSchema)]
|
||||||
|
@ -279,23 +271,22 @@ pub struct TerminalSettings {
|
||||||
impl Default for TerminalSettings {
|
impl Default for TerminalSettings {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
shell:Default::default(),
|
shell: Default::default(),
|
||||||
working_directory:Default::default(),
|
working_directory: Default::default(),
|
||||||
font_size:Default::default(),
|
font_size: Default::default(),
|
||||||
font_family:Default::default(),
|
font_family: Default::default(),
|
||||||
line_height:Default::default(),
|
line_height: Default::default(),
|
||||||
font_features:Default::default(),
|
font_features: Default::default(),
|
||||||
env:Default::default(),
|
env: Default::default(),
|
||||||
blinking:Default::default(),
|
blinking: Default::default(),
|
||||||
alternate_scroll:Default::default(),
|
alternate_scroll: Default::default(),
|
||||||
option_as_meta:Default::default(),
|
option_as_meta: Default::default(),
|
||||||
copy_on_select:Default::default(),
|
copy_on_select: Default::default(),
|
||||||
dock: DockPosition::Bottom,
|
dock: DockPosition::Bottom,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, JsonSchema, Default)]
|
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, JsonSchema, Default)]
|
||||||
#[serde(rename_all = "snake_case")]
|
#[serde(rename_all = "snake_case")]
|
||||||
pub enum TerminalLineHeight {
|
pub enum TerminalLineHeight {
|
||||||
|
@ -407,7 +398,7 @@ pub struct SettingsFileContent {
|
||||||
pub autosave: Option<Autosave>,
|
pub autosave: Option<Autosave>,
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
pub editor: EditorSettings,
|
pub editor: EditorSettings,
|
||||||
pub project_panel: ProjectPanelSettings,
|
pub project_panel: Option<ProjectPanelSettings>,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub journal: JournalSettings,
|
pub journal: JournalSettings,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
|
@ -502,7 +493,7 @@ impl Settings {
|
||||||
show_call_status_icon: defaults.show_call_status_icon.unwrap(),
|
show_call_status_icon: defaults.show_call_status_icon.unwrap(),
|
||||||
vim_mode: defaults.vim_mode.unwrap(),
|
vim_mode: defaults.vim_mode.unwrap(),
|
||||||
autosave: defaults.autosave.unwrap(),
|
autosave: defaults.autosave.unwrap(),
|
||||||
project_panel_defaults: Default::default(),
|
project_panel_defaults: defaults.project_panel.unwrap(),
|
||||||
project_panel_overrides: Default::default(),
|
project_panel_overrides: Default::default(),
|
||||||
editor_defaults: EditorSettings {
|
editor_defaults: EditorSettings {
|
||||||
tab_size: required(defaults.editor.tab_size),
|
tab_size: required(defaults.editor.tab_size),
|
||||||
|
@ -610,7 +601,7 @@ impl Settings {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.editor_overrides = data.editor;
|
self.editor_overrides = data.editor;
|
||||||
self.project_panel_overrides = data.project_panel;
|
self.project_panel_overrides = data.project_panel.unwrap_or_default();
|
||||||
self.git_overrides = data.git.unwrap_or_default();
|
self.git_overrides = data.git.unwrap_or_default();
|
||||||
self.journal_overrides = data.journal;
|
self.journal_overrides = data.journal;
|
||||||
self.terminal_defaults.font_size = data.terminal.font_size;
|
self.terminal_defaults.font_size = data.terminal.font_size;
|
||||||
|
|
Loading…
Reference in a new issue