Skip to content

Commit

Permalink
Make project panel settings live update
Browse files Browse the repository at this point in the history
  • Loading branch information
mikayla-maki committed Apr 12, 2024
1 parent 88a1070 commit 9eb92d4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
12 changes: 11 additions & 1 deletion crates/project_panel/src/project_panel.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
mod project_panel_settings;
use client::{ErrorCode, ErrorExt};
use settings::Settings;
use settings::{Settings, SettingsStore};

use db::kvp::KEY_VALUE_STORE;
use editor::{actions::Cancel, items::entry_git_aware_label_color, scroll::Autoscroll, Editor};
Expand Down Expand Up @@ -239,6 +239,16 @@ impl ProjectPanel {
})
.detach();

let mut project_panel_settings = *ProjectPanelSettings::get_global(cx);
cx.observe_global::<SettingsStore>(move |_, cx| {
let new_settings = *ProjectPanelSettings::get_global(cx);
if project_panel_settings != new_settings {
project_panel_settings = new_settings;
cx.notify();
}
})
.detach();

let mut this = Self {
project: project.clone(),
fs: workspace.app_state().fs.clone(),
Expand Down
4 changes: 2 additions & 2 deletions crates/project_panel/src/project_panel_settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ use schemars::JsonSchema;
use serde_derive::{Deserialize, Serialize};
use settings::{Settings, SettingsSources};

#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema, Copy)]
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema, Copy, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum ProjectPanelDockPosition {
Left,
Right,
}

#[derive(Deserialize, Debug, Clone, Copy)]
#[derive(Deserialize, Debug, Clone, Copy, PartialEq)]
pub struct ProjectPanelSettings {
pub default_width: Pixels,
pub dock: ProjectPanelDockPosition,
Expand Down

0 comments on commit 9eb92d4

Please sign in to comment.