Detailed changes
@@ -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": {}
}
@@ -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) {}
}
@@ -998,11 +998,11 @@ fn toggle_edit_prediction_mode(fs: Arc<dyn Fs>, 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()
});
}
@@ -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(),
}
}
@@ -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<Arc<str>, GlobSet> = FxHashMap::default();
let mut file_globs: FxHashMap<Arc<str>, Vec<String>> = 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);
}
@@ -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
@@ -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<Option<bool>>,
}
@@ -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<Vec<String>>,
/// The mode used to display edit predictions in the buffer.
/// Provider support required.
- #[serde(default)]
- pub mode: EditPredictionsMode,
+ pub mode: Option<EditPredictionsMode>,
/// Settings specific to GitHub Copilot.
- #[serde(default)]
- pub copilot: CopilotSettingsContent,
+ pub copilot: Option<CopilotSettingsContent>,
/// 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<bool>,
}
#[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<String>,
/// Disable certificate verification for the proxy (not recommended).
///
/// Default: false
- #[serde(default)]
pub proxy_no_verify: Option<bool>,
/// Enterprise URI for Copilot.
///
/// Default: none
- #[serde(default)]
pub enterprise_uri: Option<String>,
}
@@ -132,24 +121,20 @@ pub struct LanguageSettingsContent {
/// How many columns a tab should occupy.
///
/// Default: 4
- #[serde(default)]
pub tab_size: Option<NonZeroU32>,
/// Whether to indent lines using tab characters, as opposed to multiple
/// spaces.
///
/// Default: false
- #[serde(default)]
pub hard_tabs: Option<bool>,
/// How to soft-wrap long lines of text.
///
/// Default: none
- #[serde(default)]
pub soft_wrap: Option<SoftWrap>,
/// The column at which to soft-wrap lines, for buffers where soft-wrap
/// is enabled.
///
/// Default: 80
- #[serde(default)]
pub preferred_line_length: Option<u32>,
/// 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<bool>,
/// Character counts at which to show wrap guides in the editor.
///
/// Default: []
- #[serde(default)]
pub wrap_guides: Option<Vec<usize>>,
/// Indent guide related settings.
- #[serde(default)]
pub indent_guides: Option<IndentGuideSettings>,
/// Whether or not to perform a buffer format before saving.
///
/// Default: on
- #[serde(default)]
pub format_on_save: Option<FormatOnSave>,
/// 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<bool>,
/// 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<bool>,
/// How to perform a buffer format.
///
/// Default: auto
- #[serde(default)]
pub formatter: Option<SelectedFormatter>,
/// 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<PrettierSettingsContent>,
/// Whether to automatically close JSX tags.
- #[serde(default)]
pub jsx_tag_auto_close: Option<JsxTagAutoCloseSettings>,
/// Whether to use language servers to provide code intelligence.
///
/// Default: true
- #[serde(default)]
pub enable_language_server: Option<bool>,
/// 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<Vec<String>>,
/// 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<RewrapBehavior>,
/// Controls whether edit predictions are shown immediately (true)
/// or manually by triggering `editor::ShowEditPrediction` (false).
///
/// Default: true
- #[serde(default)]
pub show_edit_predictions: Option<bool>,
/// 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<Vec<String>>,
/// Whether to show tabs and spaces in the editor.
- #[serde(default)]
pub show_whitespaces: Option<ShowWhitespaceSetting>,
/// Visible characters used to render whitespace when show_whitespaces is enabled.
///
/// Default: "•" for spaces, "→" for tabs.
- #[serde(default)]
pub whitespace_map: Option<WhitespaceMap>,
/// 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<bool>,
/// Inlay hint related settings.
- #[serde(default)]
pub inlay_hints: Option<InlayHintSettings>,
/// 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
}
@@ -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<usize>, 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);