Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
edit predictions: Add `enabled_in_assistant` setting (#25767)
Agus Zubiaga82f793144e4b
diff --git a/assets/settings/default.json b/assets/settings/default.jsonindex 6cf64ffd52b..211e12b7ae6 100644--- a/assets/settings/default.json+++ b/assets/settings/default.json@@ -846,7 +846,10 @@// "mode": "eager"// 2. Display predictions inline only when holding a modifier key (alt by default).// "mode": "subtle"- "mode": "eager"+ "mode": "eager",+ // Whether edit predictions are enabled in the assistant prompt editor.+ // This setting has no effect if globally disabled.+ "enabled_in_assistant": true},// Settings specific to journaling"journal": {diff --git a/crates/assistant_context_editor/src/context_editor.rs b/crates/assistant_context_editor/src/context_editor.rsindex 71806351036..d47b8005363 100644--- a/crates/assistant_context_editor/src/context_editor.rs+++ b/crates/assistant_context_editor/src/context_editor.rs@@ -29,7 +29,10 @@ use gpui::{WeakEntity,};use indexed_docs::IndexedDocsStore;-use language::{language_settings::SoftWrap, BufferSnapshot, LspAdapterDelegate, ToOffset};+use language::{+ language_settings::{all_language_settings, SoftWrap},+ BufferSnapshot, LspAdapterDelegate, ToOffset,+};use language_model::{LanguageModelImage, LanguageModelProvider, LanguageModelProviderTosView, LanguageModelRegistry,Role,@@ -41,7 +44,7 @@ use project::lsp_store::LocalLspAdapterDelegate;use project::{Project, Worktree};use rope::Point;use serde::{Deserialize, Serialize};-use settings::{update_settings_file, Settings};+use settings::{update_settings_file, Settings, SettingsStore};use std::{any::TypeId, borrow::Cow, cmp, ops::Range, path::PathBuf, sync::Arc, time::Duration};use text::SelectionGoal;use ui::{@@ -228,6 +231,13 @@ impl ContextEditor {editor.set_completion_provider(Some(Box::new(completion_provider)));editor.set_menu_inline_completions_policy(MenuInlineCompletionsPolicy::Never);editor.set_collaboration_hub(Box::new(project.clone()));++ let show_edit_predictions = all_language_settings(None, cx)+ .edit_predictions+ .enabled_in_assistant;++ editor.set_show_edit_predictions(Some(show_edit_predictions), window, cx);+editor});@@ -236,6 +246,7 @@ impl ContextEditor {cx.subscribe_in(&context, window, Self::handle_context_event),cx.subscribe_in(&editor, window, Self::handle_editor_event),cx.subscribe_in(&editor, window, Self::handle_editor_search_event),+ cx.observe_global_in::<SettingsStore>(window, Self::settings_changed),];let fs_clone = fs.clone();@@ -286,6 +297,16 @@ impl ContextEditor {this}+ fn settings_changed(&mut self, window: &mut Window, cx: &mut Context<Self>) {+ self.editor.update(cx, |editor, cx| {+ let show_edit_predictions = all_language_settings(None, cx)+ .edit_predictions+ .enabled_in_assistant;++ editor.set_show_edit_predictions(Some(show_edit_predictions), window, cx);+ });+ }+pub fn context(&self) -> &Entity<AssistantContext> {&self.context}diff --git a/crates/language/src/language_settings.rs b/crates/language/src/language_settings.rsindex 5a27427d6ec..1b6168d7596 100644--- a/crates/language/src/language_settings.rs+++ b/crates/language/src/language_settings.rs@@ -236,6 +236,9 @@ pub struct EditPredictionSettings {pub mode: EditPredictionsMode,/// Settings specific to GitHub Copilot.pub copilot: CopilotSettings,+ /// Whether edit predictions are enabled in the assistant prompt editor.+ /// This setting has no effect if globally disabled.+ pub enabled_in_assistant: bool,}impl EditPredictionSettings {@@ -500,6 +503,10 @@ pub struct EditPredictionSettingsContent {/// Settings specific to GitHub Copilot.#[serde(default)]pub copilot: 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_assistant: bool,}#[derive(Clone, Debug, Default, Serialize, Deserialize, JsonSchema, PartialEq)]@@ -1119,6 +1126,12 @@ impl settings::Settings for AllLanguageSettings {}).unwrap_or_default();+ let mut edit_predictions_enabled_in_assistant = default_value+ .edit_predictions+ .as_ref()+ .map(|settings| settings.enabled_in_assistant)+ .unwrap_or(true);+let mut file_types: HashMap<Arc<str>, GlobSet> = HashMap::default();for (language, suffixes) in &default_value.file_types {@@ -1145,6 +1158,7 @@ impl settings::Settings for AllLanguageSettings {if let Some(edit_predictions) = user_settings.edit_predictions.as_ref() {edit_predictions_mode = edit_predictions.mode;+ edit_predictions_enabled_in_assistant = edit_predictions.enabled_in_assistant;if let Some(disabled_globs) = edit_predictions.disabled_globs.as_ref() {completion_globs.extend(disabled_globs.iter());@@ -1224,6 +1238,7 @@ impl settings::Settings for AllLanguageSettings {.collect(),mode: edit_predictions_mode,copilot: copilot_settings,+ enabled_in_assistant: edit_predictions_enabled_in_assistant,},defaults,languages,diff --git a/docs/src/configuring-zed.md b/docs/src/configuring-zed.mdindex 74ec806d699..5587f9dbfcf 100644--- a/docs/src/configuring-zed.md+++ b/docs/src/configuring-zed.md@@ -406,6 +406,12 @@ There are two options to choose from:List of `string` values.+### Enabled in Assistant++- Description: Whether to show edit predictions in the assistant's prompt editor.+- Setting: `enabled_in_assistant`+- Default: `true`+## Edit Predictions Disabled in- Description: A list of language scopes in which edit predictions should be disabled.