settings_ui: Collect all settings files (#38816)
Closes #ISSUE Updates the settings editor to collect all known settings files from the settings store, in order to show them in the UI. Additionally adds a fake worktree instantiation in the settings UI example binary in order to have more than one file available when testing. Release Notes: - N/A *or* Added/Fixed/Improved ...
This commit is contained in:
@@ -24,7 +24,8 @@ pub use keymap_file::{
|
||||
pub use settings_file::*;
|
||||
pub use settings_json::*;
|
||||
pub use settings_store::{
|
||||
InvalidSettingsError, LocalSettingsKind, Settings, SettingsKey, SettingsLocation, SettingsStore,
|
||||
InvalidSettingsError, LocalSettingsKind, Settings, SettingsFile, SettingsKey, SettingsLocation,
|
||||
SettingsStore,
|
||||
};
|
||||
|
||||
pub use vscode_import::{VsCodeSettings, VsCodeSettingsSource};
|
||||
|
||||
@@ -156,6 +156,16 @@ pub struct SettingsStore {
|
||||
mpsc::UnboundedSender<Box<dyn FnOnce(AsyncApp) -> LocalBoxFuture<'static, Result<()>>>>,
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq)]
|
||||
pub enum SettingsFile {
|
||||
User,
|
||||
Global,
|
||||
Extension,
|
||||
Server,
|
||||
Default,
|
||||
Local((WorktreeId, Arc<Path>)),
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Editorconfig {
|
||||
pub is_root: bool,
|
||||
@@ -479,6 +489,36 @@ impl SettingsStore {
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
pub fn get_all_files(&self) -> Vec<SettingsFile> {
|
||||
let mut files = Vec::from_iter(
|
||||
self.local_settings
|
||||
.keys()
|
||||
// rev because these are sorted by path, so highest precedence is last
|
||||
.rev()
|
||||
.cloned()
|
||||
.map(SettingsFile::Local),
|
||||
);
|
||||
|
||||
if self.server_settings.is_some() {
|
||||
files.push(SettingsFile::Server);
|
||||
}
|
||||
// ignoring profiles
|
||||
// ignoring os profiles
|
||||
// ignoring release channel profiles
|
||||
|
||||
if self.user_settings.is_some() {
|
||||
files.push(SettingsFile::User);
|
||||
}
|
||||
if self.extension_settings.is_some() {
|
||||
files.push(SettingsFile::Extension);
|
||||
}
|
||||
if self.global_settings.is_some() {
|
||||
files.push(SettingsFile::Global);
|
||||
}
|
||||
files.push(SettingsFile::Default);
|
||||
files
|
||||
}
|
||||
}
|
||||
|
||||
impl SettingsStore {
|
||||
|
||||
Reference in New Issue
Block a user