Watch the themes directory for changes (#7173)
This PR makes Zed watch the themes directory for changes. When theme files are added or modified, we reload the theme and apply any changes to Zed. Release Notes: - Added live reloading for the themes directory.
This commit is contained in:
parent
2187513026
commit
c4083c3cf6
2 changed files with 91 additions and 38 deletions
|
@ -255,19 +255,23 @@ impl ThemeRegistry {
|
|||
continue;
|
||||
};
|
||||
|
||||
let Some(reader) = fs.open_sync(&theme_path).await.log_err() else {
|
||||
continue;
|
||||
};
|
||||
|
||||
let Some(theme) = serde_json_lenient::from_reader(reader).log_err() else {
|
||||
continue;
|
||||
};
|
||||
|
||||
self.insert_user_theme_families([theme]);
|
||||
self.load_user_theme(&theme_path, fs.clone())
|
||||
.await
|
||||
.log_err();
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Loads the user theme from the specified path and adds it to the registry.
|
||||
pub async fn load_user_theme(&self, theme_path: &Path, fs: Arc<dyn Fs>) -> Result<()> {
|
||||
let reader = fs.open_sync(&theme_path).await?;
|
||||
let theme = serde_json_lenient::from_reader(reader)?;
|
||||
|
||||
self.insert_user_theme_families([theme]);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for ThemeRegistry {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue