mirror of
https://github.com/zed-industries/zed.git
synced 2024-11-08 07:35:01 +03:00
Once again respect user settings for git gutter
Co-Authored-By: Mikayla Maki <mikayla@zed.dev>
This commit is contained in:
parent
e6487de069
commit
6f6d72890a
@ -663,12 +663,8 @@ impl LocalWorktree {
|
||||
let fs = self.fs.clone();
|
||||
let snapshot = self.snapshot();
|
||||
|
||||
let files_included = cx
|
||||
.global::<Settings>()
|
||||
.git
|
||||
.git_gutter
|
||||
.expect("This should be Some by setting setup")
|
||||
.files_included;
|
||||
let settings = cx.global::<Settings>();
|
||||
let files_included = settings.git_gutter().files_included(settings);
|
||||
|
||||
cx.spawn(|this, mut cx| async move {
|
||||
let text = fs.load(&abs_path).await?;
|
||||
|
@ -33,6 +33,7 @@ pub struct Settings {
|
||||
pub editor_defaults: EditorSettings,
|
||||
pub editor_overrides: EditorSettings,
|
||||
pub git: GitSettings,
|
||||
pub git_overrides: GitSettings,
|
||||
pub terminal_defaults: TerminalSettings,
|
||||
pub terminal_overrides: TerminalSettings,
|
||||
pub language_defaults: HashMap<Arc<str>, EditorSettings>,
|
||||
@ -60,10 +61,21 @@ pub struct GitSettings {
|
||||
|
||||
#[derive(Clone, Copy, Debug, Default, Deserialize, JsonSchema)]
|
||||
pub struct GitGutter {
|
||||
pub files_included: GitFilesIncluded,
|
||||
pub files_included: Option<GitFilesIncluded>,
|
||||
pub debounce_delay_millis: Option<u64>,
|
||||
}
|
||||
|
||||
impl GitGutter {
|
||||
pub fn files_included(&self, settings: &Settings) -> GitFilesIncluded {
|
||||
self.files_included.unwrap_or_else(|| {
|
||||
settings
|
||||
.git.git_gutter.expect("git_gutter must be some in defaults.json")
|
||||
.files_included
|
||||
.expect("Should be some in defaults.json")
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Default, Deserialize, JsonSchema, PartialEq, Eq)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum GitFilesIncluded {
|
||||
@ -276,6 +288,7 @@ impl Settings {
|
||||
},
|
||||
editor_overrides: Default::default(),
|
||||
git: defaults.git.unwrap(),
|
||||
git_overrides: Default::default(),
|
||||
terminal_defaults: Default::default(),
|
||||
terminal_overrides: Default::default(),
|
||||
language_defaults: defaults.languages,
|
||||
@ -327,6 +340,7 @@ impl Settings {
|
||||
}
|
||||
|
||||
self.editor_overrides = data.editor;
|
||||
self.git_overrides = data.git.unwrap_or_default();
|
||||
self.terminal_defaults.font_size = data.terminal.font_size;
|
||||
self.terminal_overrides = data.terminal;
|
||||
self.language_overrides = data.languages;
|
||||
@ -382,6 +396,14 @@ impl Settings {
|
||||
.expect("missing default")
|
||||
}
|
||||
|
||||
pub fn git_gutter(&self) -> GitGutter {
|
||||
self.git_overrides.git_gutter.unwrap_or_else(|| {
|
||||
self.git
|
||||
.git_gutter
|
||||
.expect("git_gutter should be some by setting setup")
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(any(test, feature = "test-support"))]
|
||||
pub fn test(cx: &gpui::AppContext) -> Settings {
|
||||
Settings {
|
||||
@ -408,10 +430,11 @@ impl Settings {
|
||||
terminal_overrides: Default::default(),
|
||||
git: GitSettings {
|
||||
git_gutter: Some(GitGutter {
|
||||
files_included: GitFilesIncluded::All,
|
||||
files_included: Some(GitFilesIncluded::All),
|
||||
debounce_delay_millis: None,
|
||||
}),
|
||||
},
|
||||
git_overrides: Default::default(),
|
||||
language_defaults: Default::default(),
|
||||
language_overrides: Default::default(),
|
||||
lsp: Default::default(),
|
||||
|
@ -734,12 +734,18 @@ impl<T: Item> ItemHandle for ViewHandle<T> {
|
||||
);
|
||||
}
|
||||
|
||||
let debounce_delay = cx
|
||||
.global::<Settings>()
|
||||
.git
|
||||
let settings = cx.global::<Settings>();
|
||||
let debounce_delay = settings
|
||||
.git_overrides
|
||||
.git_gutter
|
||||
.expect("This should be Some by setting setup")
|
||||
.unwrap_or_else(|| {
|
||||
settings
|
||||
.git
|
||||
.git_gutter
|
||||
.expect("This should be Some by setting setup")
|
||||
})
|
||||
.debounce_delay_millis;
|
||||
|
||||
let item = item.clone();
|
||||
|
||||
if let Some(delay) = debounce_delay {
|
||||
|
Loading…
Reference in New Issue
Block a user