From 27b59c0dd130bac0b6dc26d46a9d04bdea8702a2 Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Wed, 17 Sep 2025 14:38:29 -0600 Subject: [PATCH] TEMP --- assets/settings/default.json | 24 +++++----- crates/agent_ui/src/slash_command_settings.rs | 27 ++--------- .../src/edit_prediction_button.rs | 4 +- .../file_finder/src/file_finder_settings.rs | 2 +- crates/language/src/language_settings.rs | 45 +++++++++---------- crates/onboarding/src/basics_page.rs | 14 +++++- crates/settings/src/settings_content.rs | 2 +- .../settings/src/settings_content/language.rs | 43 +++--------------- crates/settings/src/settings_store.rs | 6 ++- 9 files changed, 65 insertions(+), 102 deletions(-) diff --git a/assets/settings/default.json b/assets/settings/default.json index 2a6f49c3736a49bba64d2ddb1174969c9e792807..8dd3e46eec3f466a2647cf55c57dd4ef32c01776 100644 --- a/assets/settings/default.json +++ b/assets/settings/default.json @@ -937,14 +937,6 @@ /// Default: false "use_modifier_to_send": false }, - // The settings for slash commands. - "slash_commands": { - // Settings for the `/project` slash command. - "project": { - // Whether `/project` is enabled. - "enabled": false - } - }, // Whether the screen sharing icon is shown in the os status bar. "show_call_status_icon": true, // Whether to use language servers to provide code intelligence. @@ -1287,7 +1279,13 @@ // }, // Whether edit predictions are enabled when editing text threads. // This setting has no effect if globally disabled. - "enabled_in_text_threads": true + "enabled_in_text_threads": true, + + "copilot": { + "enterprise_uri": null, + "proxy": null, + "proxy_no_verify": null + } }, // Settings specific to journaling "journal": { @@ -2011,5 +2009,11 @@ // } // } // } - "profiles": [] + "profiles": [], + + /// A map of log scopes to the desired log level. + /// Useful for filtering out noisy logs or enabling more verbose logging. + /// + /// Example: {"log": {"client": "warn"}} + "log": {} } diff --git a/crates/agent_ui/src/slash_command_settings.rs b/crates/agent_ui/src/slash_command_settings.rs index 1655c54da05fbec5f28c695d2668f10f86e4f1e4..f0a04c6b49984ae94d629f1bbfa96c6de4e01606 100644 --- a/crates/agent_ui/src/slash_command_settings.rs +++ b/crates/agent_ui/src/slash_command_settings.rs @@ -1,6 +1,5 @@ use gpui::App; use settings::Settings; -use util::MergeFrom; /// Settings for slash commands. #[derive(Debug, Default, Clone)] @@ -18,31 +17,11 @@ pub struct CargoWorkspaceCommandSettings { // todo!() I think this setting is bogus... default.json has "slash_commands": {"project"} impl Settings for SlashCommandSettings { - fn from_defaults(content: &settings::SettingsContent, _cx: &mut App) -> Self { + fn from_defaults(_content: &settings::SettingsContent, _cx: &mut App) -> Self { Self { - cargo_workspace: CargoWorkspaceCommandSettings { - enabled: content - .project - .slash_commands - .clone() - .unwrap() - .cargo_workspace - .unwrap() - .enabled - .unwrap(), - }, + cargo_workspace: CargoWorkspaceCommandSettings { enabled: false }, } } - fn refine(&mut self, content: &settings::SettingsContent, _cx: &mut App) { - let Some(slash_command) = content.project.slash_commands.as_ref() else { - return; - }; - let Some(cargo_workspace) = slash_command.cargo_workspace.as_ref() else { - return; - }; - self.cargo_workspace - .enabled - .merge_from(&cargo_workspace.enabled); - } + fn refine(&mut self, _content: &settings::SettingsContent, _cx: &mut App) {} } diff --git a/crates/edit_prediction_button/src/edit_prediction_button.rs b/crates/edit_prediction_button/src/edit_prediction_button.rs index 55e0612ef2f6f68e69124641aebcc685493a84be..8822c05f6c4d1842fd74d45d876f64736eb62fbc 100644 --- a/crates/edit_prediction_button/src/edit_prediction_button.rs +++ b/crates/edit_prediction_button/src/edit_prediction_button.rs @@ -998,11 +998,11 @@ fn toggle_edit_prediction_mode(fs: Arc, mode: EditPredictionsMode, cx: & update_settings_file(fs, cx, move |settings, _cx| { if let Some(edit_predictions) = settings.project.all_languages.edit_predictions.as_mut() { - edit_predictions.mode = mode; + edit_predictions.mode = Some(mode); } else { settings.project.all_languages.edit_predictions = Some(settings::EditPredictionSettingsContent { - mode, + mode: Some(mode), ..Default::default() }); } diff --git a/crates/file_finder/src/file_finder_settings.rs b/crates/file_finder/src/file_finder_settings.rs index 22d60160f535b674ef7ab7a3d9d967e924b43bbb..3f974b7412d740dd30e96fdd61487ac8774daa0e 100644 --- a/crates/file_finder/src/file_finder_settings.rs +++ b/crates/file_finder/src/file_finder_settings.rs @@ -19,7 +19,7 @@ impl Settings for FileFinderSettings { file_icons: file_finder.file_icons.unwrap(), modal_max_width: file_finder.modal_max_width.unwrap().into(), skip_focus_for_active_in_search: file_finder.skip_focus_for_active_in_search.unwrap(), - include_ignored: file_finder.include_ignored.unwrap(), + include_ignored: file_finder.include_ignored.flatten(), } } diff --git a/crates/language/src/language_settings.rs b/crates/language/src/language_settings.rs index 72271dbd58c5def6a4017a94e811289f2f5d8b8a..22f1d5df982a1796c236f5813b273e5e6e78ae7b 100644 --- a/crates/language/src/language_settings.rs +++ b/crates/language/src/language_settings.rs @@ -430,33 +430,25 @@ impl settings::Settings for AllLanguageSettings { .features .as_ref() .and_then(|f| f.edit_prediction_provider); - let edit_predictions_mode = all_languages.edit_predictions.as_ref().unwrap().mode; - let disabled_globs: HashSet<&String> = all_languages - .edit_predictions - .as_ref() - .unwrap() + let edit_predictions = all_languages.edit_predictions.clone().unwrap(); + let edit_predictions_mode = edit_predictions.mode.unwrap(); + + let disabled_globs: HashSet<&String> = edit_predictions .disabled_globs .as_ref() .unwrap() .iter() .collect(); - let copilot_settings = all_languages - .edit_predictions - .as_ref() - .map(|settings| CopilotSettings { - proxy: settings.copilot.proxy.clone(), - proxy_no_verify: settings.copilot.proxy_no_verify, - enterprise_uri: settings.copilot.enterprise_uri.clone(), - }) - .unwrap_or_default(); + let copilot = edit_predictions.copilot.unwrap(); + let copilot_settings = CopilotSettings { + proxy: copilot.proxy, + proxy_no_verify: copilot.proxy_no_verify, + enterprise_uri: copilot.enterprise_uri, + }; - let enabled_in_text_threads = all_languages - .edit_predictions - .as_ref() - .map(|settings| settings.enabled_in_text_threads) - .unwrap_or(true); + let enabled_in_text_threads = edit_predictions.enabled_in_text_threads.unwrap(); let mut file_types: FxHashMap, GlobSet> = FxHashMap::default(); let mut file_globs: FxHashMap, Vec> = FxHashMap::default(); @@ -511,9 +503,12 @@ impl settings::Settings for AllLanguageSettings { } if let Some(edit_predictions) = all_languages.edit_predictions.as_ref() { - self.edit_predictions.mode = edit_predictions.mode; - self.edit_predictions.enabled_in_text_threads = - edit_predictions.enabled_in_text_threads; + self.edit_predictions + .mode + .merge_from(&edit_predictions.mode); + self.edit_predictions + .enabled_in_text_threads + .merge_from(&edit_predictions.enabled_in_text_threads); if let Some(disabled_globs) = edit_predictions.disabled_globs.as_ref() { self.edit_predictions @@ -531,7 +526,7 @@ impl settings::Settings for AllLanguageSettings { if let Some(proxy) = all_languages .edit_predictions .as_ref() - .and_then(|settings| settings.copilot.proxy.clone()) + .and_then(|settings| settings.copilot.as_ref()?.proxy.clone()) { self.edit_predictions.copilot.proxy = Some(proxy); } @@ -539,7 +534,7 @@ impl settings::Settings for AllLanguageSettings { if let Some(proxy_no_verify) = all_languages .edit_predictions .as_ref() - .and_then(|settings| settings.copilot.proxy_no_verify) + .and_then(|settings| settings.copilot.as_ref()?.proxy_no_verify) { self.edit_predictions.copilot.proxy_no_verify = Some(proxy_no_verify); } @@ -547,7 +542,7 @@ impl settings::Settings for AllLanguageSettings { if let Some(enterprise_uri) = all_languages .edit_predictions .as_ref() - .and_then(|settings| settings.copilot.enterprise_uri.clone()) + .and_then(|settings| settings.copilot.as_ref()?.enterprise_uri.clone()) { self.edit_predictions.copilot.enterprise_uri = Some(enterprise_uri); } diff --git a/crates/onboarding/src/basics_page.rs b/crates/onboarding/src/basics_page.rs index 09ca95b1a2a44be8bdcfec36a3b032de67b91222..d705d64bfe0f7cdd65e18196bebcd888d5a2fb5f 100644 --- a/crates/onboarding/src/basics_page.rs +++ b/crates/onboarding/src/basics_page.rs @@ -250,7 +250,12 @@ fn render_telemetry_section(tab_index: &mut isize, cx: &App) -> impl IntoElement update_settings_file( fs.clone(), cx, - move |setting, _| setting.telemetry.get_or_insert_default().metrics = Some(enabled), + move |setting, _| { + dbg!(&setting.telemetry); + setting.telemetry.get_or_insert_default().metrics = Some(enabled); + dbg!(&setting.telemetry); + } + , ); // This telemetry event shouldn't fire when it's off. If it does we'll be alerted @@ -289,7 +294,12 @@ fn render_telemetry_section(tab_index: &mut isize, cx: &App) -> impl IntoElement update_settings_file( fs.clone(), cx, - move |setting, _| setting.telemetry.get_or_insert_default().diagnostics = Some(enabled), + move |setting, _| { + dbg!(&setting.telemetry); + setting.telemetry.get_or_insert_default().diagnostics = Some(enabled); + dbg!(&setting.telemetry); + }, + ); // This telemetry event shouldn't fire when it's off. If it does we'll be alerted diff --git a/crates/settings/src/settings_content.rs b/crates/settings/src/settings_content.rs index 5321201384edf12e5ad662be9e54d70499713c99..86a2ea9d286acf33e75559794cccfbe1bbf6a4e1 100644 --- a/crates/settings/src/settings_content.rs +++ b/crates/settings/src/settings_content.rs @@ -526,7 +526,7 @@ pub struct FileFinderSettingsContent { /// * `None`: Be smart and search for ignored when called from a gitignored worktree /// /// Default: None - /// todo!() -> Change this type to an enum + /// todo() -> Change this type to an enum pub include_ignored: Option>, } diff --git a/crates/settings/src/settings_content/language.rs b/crates/settings/src/settings_content/language.rs index e9588ac8de21181d2414fcf15f179b4b9f2966f7..7a679a2a06caf4468d5872dc1c06fb2462c88735 100644 --- a/crates/settings/src/settings_content/language.rs +++ b/crates/settings/src/settings_content/language.rs @@ -57,23 +57,15 @@ pub struct EditPredictionSettingsContent { /// A list of globs representing files that edit predictions should be disabled for. /// This list adds to a pre-existing, sensible default set of globs. /// Any additional ones you add are combined with them. - #[serde(default)] pub disabled_globs: Option>, /// The mode used to display edit predictions in the buffer. /// Provider support required. - #[serde(default)] - pub mode: EditPredictionsMode, + pub mode: Option, /// Settings specific to GitHub Copilot. - #[serde(default)] - pub copilot: CopilotSettingsContent, + pub copilot: Option, /// Whether edit predictions are enabled in the assistant prompt editor. /// This has no effect if globally disabled. - #[serde(default = "default_true")] - pub enabled_in_text_threads: bool, -} - -fn default_true() -> bool { - true + pub enabled_in_text_threads: Option, } #[derive(Clone, Debug, Default, Serialize, Deserialize, JsonSchema, PartialEq)] @@ -81,17 +73,14 @@ pub struct CopilotSettingsContent { /// HTTP/HTTPS proxy to use for Copilot. /// /// Default: none - #[serde(default)] pub proxy: Option, /// Disable certificate verification for the proxy (not recommended). /// /// Default: false - #[serde(default)] pub proxy_no_verify: Option, /// Enterprise URI for Copilot. /// /// Default: none - #[serde(default)] pub enterprise_uri: Option, } @@ -132,24 +121,20 @@ pub struct LanguageSettingsContent { /// How many columns a tab should occupy. /// /// Default: 4 - #[serde(default)] pub tab_size: Option, /// Whether to indent lines using tab characters, as opposed to multiple /// spaces. /// /// Default: false - #[serde(default)] pub hard_tabs: Option, /// How to soft-wrap long lines of text. /// /// Default: none - #[serde(default)] pub soft_wrap: Option, /// The column at which to soft-wrap lines, for buffers where soft-wrap /// is enabled. /// /// Default: 80 - #[serde(default)] pub preferred_line_length: Option, /// Whether to show wrap guides in the editor. Setting this to true will /// show a guide at the 'preferred_line_length' value if softwrap is set to @@ -157,52 +142,42 @@ pub struct LanguageSettingsContent { /// by the 'wrap_guides' setting. /// /// Default: true - #[serde(default)] pub show_wrap_guides: Option, /// Character counts at which to show wrap guides in the editor. /// /// Default: [] - #[serde(default)] pub wrap_guides: Option>, /// Indent guide related settings. - #[serde(default)] pub indent_guides: Option, /// Whether or not to perform a buffer format before saving. /// /// Default: on - #[serde(default)] pub format_on_save: Option, /// Whether or not to remove any trailing whitespace from lines of a buffer /// before saving it. /// /// Default: true - #[serde(default)] pub remove_trailing_whitespace_on_save: Option, /// Whether or not to ensure there's a single newline at the end of a buffer /// when saving it. /// /// Default: true - #[serde(default)] pub ensure_final_newline_on_save: Option, /// How to perform a buffer format. /// /// Default: auto - #[serde(default)] pub formatter: Option, /// Zed's Prettier integration settings. /// Allows to enable/disable formatting with Prettier /// and configure default Prettier, used when no project-level Prettier installation is found. /// /// Default: off - #[serde(default)] pub prettier: Option, /// Whether to automatically close JSX tags. - #[serde(default)] pub jsx_tag_auto_close: Option, /// Whether to use language servers to provide code intelligence. /// /// Default: true - #[serde(default)] pub enable_language_server: Option, /// The list of language servers to use (or disable) for this language. /// @@ -212,7 +187,6 @@ pub struct LanguageSettingsContent { /// - `"..."` - A placeholder to refer to the **rest** of the registered language servers for this language. /// /// Default: ["..."] - #[serde(default)] pub language_servers: Option>, /// Controls where the `editor::Rewrap` action is allowed for this language. /// @@ -220,13 +194,11 @@ pub struct LanguageSettingsContent { /// allowed everywhere. /// /// Default: "in_comments" - #[serde(default)] pub allow_rewrap: Option, /// Controls whether edit predictions are shown immediately (true) /// or manually by triggering `editor::ShowEditPrediction` (false). /// /// Default: true - #[serde(default)] pub show_edit_predictions: Option, /// Controls whether edit predictions are shown in the given language /// scopes. @@ -234,23 +206,18 @@ pub struct LanguageSettingsContent { /// Example: ["string", "comment"] /// /// Default: [] - #[serde(default)] pub edit_predictions_disabled_in: Option>, /// Whether to show tabs and spaces in the editor. - #[serde(default)] pub show_whitespaces: Option, /// Visible characters used to render whitespace when show_whitespaces is enabled. /// /// Default: "•" for spaces, "→" for tabs. - #[serde(default)] pub whitespace_map: Option, /// Whether to start a new line with a comment when a previous line is a comment as well. /// /// Default: true - #[serde(default)] pub extend_comment_on_newline: Option, /// Inlay hint related settings. - #[serde(default)] pub inlay_hints: Option, /// Whether to automatically type closing characters for you. For example, /// when you type (, Zed will automatically add a closing ) at the correct position. @@ -862,6 +829,10 @@ pub struct IndentGuideSettings { pub background_coloring: IndentGuideBackgroundColoring, } +fn default_true() -> bool { + true +} + fn line_width() -> u32 { 1 } diff --git a/crates/settings/src/settings_store.rs b/crates/settings/src/settings_store.rs index fa4cb8dd0db161e39de828043a2651a97d62942e..15d7ef280c2e81bd428860f3d0390519731b5201 100644 --- a/crates/settings/src/settings_store.rs +++ b/crates/settings/src/settings_store.rs @@ -424,6 +424,7 @@ impl SettingsStore { async move { let res = async move { let old_text = Self::load_settings(&fs).await?; + dbg!(&old_text); let new_text = update(old_text, cx)?; let settings_path = paths::settings_file().as_path(); if fs.is_file(settings_path).await { @@ -554,7 +555,10 @@ impl SettingsStore { text: &str, update: impl FnOnce(&mut SettingsContent), ) -> Vec<(Range, String)> { - let old_content: UserSettingsContent = serde_json::from_str(text).unwrap_or_default(); + dbg!(&text); + let old_content: UserSettingsContent = + parse_json_with_comments(text).log_err().unwrap_or_default(); + dbg!(&old_content); let mut new_content = old_content.clone(); update(&mut new_content.content);