Add support for "..." in edit_predictions_disabled_in (#64546)

## Objective

Let projects and language-specific settings add scopes where edit
predictions are disabled without repeating inherited scopes.

Part of #64399.

## Solution

Extend the `"..."` convention from #62769, #64222, #64440, #64484, and
#64540 to `edit_predictions_disabled_in`. For example, a global
`["comment"]` and a language override of `["string", "..."]` disable
predictions in both scopes.

Inherited scopes are inserted at `"..."`, and duplicates keep their
first occurrence. Omitting the marker replaces the list, `[]` clears it,
and omitting the setting preserves inheritance. The default remains
`[]`.

## Testing

Tested on macOS through settings loading, covering project and
language-specific overrides, inheritance, replacement, and clearing. The
language settings tests passed. Live editor behavior has not been
checked manually.

To check manually, configure global `["comment"]` and a language
override of `["string", "..."]`. Confirm predictions are disabled in
both scopes, then remove `"..."` and repeat with `[]` to check
replacement and clearing.

## Self-Review Checklist:

- [x] I’ve reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content adheres to Zed’s UI standards
([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
and
[icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md)
guidelines)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

---

Release Notes:

- Added support for `"..."` in `edit_predictions_disabled_in` so project
and language-specific settings can extend inherited scopes.

---------

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
This commit is contained in:
Dom PoradaandKirill Bulatov authored and GitHub committed 2026-09-21 14:24:18 +00:00
1 parent d1f71d8cd0
commit fbd6cc5dcf
5 files changed
+199 -30

No files matched your search

+12 -2
View File
@@ -540,8 +540,18 @@
// Controls whether edit predictions are shown immediately (true)
// or manually by triggering `editor::ShowEditPrediction` (false).
"show_edit_predictions": true,
// Controls whether edit predictions are shown in a given language scope.
// Example: ["string", "comment"]
// Disable edit predictions in these language scopes, such as "comment" and
// "string".
//
// Use `"..."` to add scopes without repeating the inherited list. In project
// settings, it extends the user or parent configuration value. In
// language-specific settings, it extends the scopes inherited by that
// language. Omit `"..."` to replace the inherited list.
//
// Inherited scopes are inserted at `"..."`, and duplicates keep their first
// occurrence.
//
// Set `[]` to clear the inherited list. Omit this setting to inherit it unchanged.
"edit_predictions_disabled_in": [],
// Whether to show tabs and spaces in the editor.
// This setting can take four values:
+146 -3
View File
@@ -118,8 +118,18 @@ pub struct LanguageSettings {
/// Controls whether edit predictions are shown immediately (true)
/// or manually by triggering `editor::ShowEditPrediction` (false).
pub show_edit_predictions: bool,
/// Controls whether edit predictions are shown in the given language
/// scopes.
/// Disable edit predictions in these language scopes, such as "comment" and
/// "string".
///
/// Use `"..."` to add scopes without repeating the inherited list. In project
/// settings, it extends the user or parent configuration value. In
/// language-specific settings, it extends the scopes inherited by that
/// language. Omit `"..."` to replace the inherited list.
///
/// Inherited scopes are inserted at `"..."`, and duplicates keep their first
/// occurrence.
///
/// Set `[]` to clear the inherited list. Omit this setting to inherit it unchanged.
pub edit_predictions_disabled_in: Vec<String>,
/// Whether to show tabs and spaces in the editor.
pub show_whitespaces: settings::ShowWhitespaceSetting,
@@ -861,7 +871,7 @@ impl settings::Settings for AllLanguageSettings {
document_symbols: settings.document_symbols.unwrap(),
allow_rewrap: settings.allow_rewrap.unwrap(),
show_edit_predictions: settings.show_edit_predictions.unwrap(),
edit_predictions_disabled_in: settings.edit_predictions_disabled_in.unwrap(),
edit_predictions_disabled_in: settings.edit_predictions_disabled_in.unwrap().0,
show_whitespaces: settings.show_whitespaces.unwrap(),
whitespace_map: WhitespaceMap {
space: SharedString::new(whitespace_map.space.unwrap().to_string()),
@@ -1116,6 +1126,139 @@ mod tests {
});
}
#[gpui::test]
fn test_edit_predictions_disabled_in_language_overrides(cx: &mut App) {
let mut store = SettingsStore::new(cx, &settings::default_settings());
store.register_setting::<AllLanguageSettings>();
assert!(
store
.get::<AllLanguageSettings>(None)
.defaults
.edit_predictions_disabled_in
.is_empty()
);
for (language_settings, expected) in [
(serde_json::json!({}), vec!["comment"]),
(
serde_json::json!({"edit_predictions_disabled_in": ["string", "..."]}),
vec!["string", "comment"],
),
(
serde_json::json!({"edit_predictions_disabled_in": ["string"]}),
vec!["string"],
),
(
serde_json::json!({"edit_predictions_disabled_in": []}),
vec![],
),
] {
store
.set_user_settings(
&serde_json::json!({
"edit_predictions_disabled_in": ["comment"],
"languages": {"Rust": language_settings},
})
.to_string(),
cx,
)
.expect("user settings should load");
let settings = store.get::<AllLanguageSettings>(None);
assert_eq!(settings.defaults.edit_predictions_disabled_in, ["comment"]);
assert_eq!(
settings
.languages
.get(&LanguageName::from("Rust"))
.expect("Rust settings should load")
.edit_predictions_disabled_in,
expected,
"language settings: {language_settings}"
);
}
}
#[gpui::test]
fn test_edit_predictions_disabled_in_project_overrides(cx: &mut App) {
let mut store = SettingsStore::new(cx, &settings::default_settings());
store.register_setting::<AllLanguageSettings>();
let worktree_id = WorktreeId::from_usize(1);
let root = LocalSettingsPath::InWorktree(rel_path("root").into());
let child = LocalSettingsPath::InWorktree(rel_path("root/child").into());
store
.set_user_settings(r#"{"edit_predictions_disabled_in":["comment"]}"#, cx)
.expect("user settings should load");
store
.set_local_settings(
worktree_id,
root,
LocalSettingsKind::Settings,
Some(r#"{"edit_predictions_disabled_in":["string","..."]}"#),
cx,
)
.expect("project settings should load");
for (overrides, expected) in [
(serde_json::json!({}), vec!["string", "comment"]),
(
serde_json::json!({"edit_predictions_disabled_in": ["documentation", "..."]}),
vec!["documentation", "string", "comment"],
),
(
serde_json::json!({"edit_predictions_disabled_in": ["documentation"]}),
vec!["documentation"],
),
(
serde_json::json!({"edit_predictions_disabled_in": []}),
vec![],
),
] {
for language_specific in [false, true] {
let content = if language_specific {
serde_json::json!({"languages": {"Rust": overrides}})
} else {
overrides.clone()
};
store
.set_local_settings(
worktree_id,
child.clone(),
LocalSettingsKind::Settings,
Some(&content.to_string()),
cx,
)
.expect("child settings should load");
let settings = store.get::<AllLanguageSettings>(Some(SettingsLocation {
worktree_id,
path: rel_path("root/child/file.rs"),
}));
let resolved = if language_specific {
assert_eq!(
settings.defaults.edit_predictions_disabled_in,
["string", "comment"]
);
settings
.languages
.get(&LanguageName::from("Rust"))
.expect("Rust settings should load")
} else {
&settings.defaults
};
assert_eq!(
resolved.edit_predictions_disabled_in, expected,
"project settings: {content}"
);
}
}
assert_eq!(
store
.get::<AllLanguageSettings>(None)
.defaults
.edit_predictions_disabled_in,
["comment"]
);
}
#[gpui::test]
fn test_edit_predictions_disabled_globs_replace_and_clear(cx: &mut App) {
let mut store = SettingsStore::new(cx, &settings::default_settings());
+30 -5
View File
@@ -656,13 +656,38 @@ pub struct LanguageSettingsContent {
///
/// Default: true
pub show_edit_predictions: Option<bool>,
/// Controls whether edit predictions are shown in the given language
/// scopes.
/// Disable edit predictions in these language scopes, such as "comment" and
/// "string".
///
/// Example: ["string", "comment"]
/// Default:
///
/// Default: []
pub edit_predictions_disabled_in: Option<Vec<String>>,
/// ```json
/// {
/// "edit_predictions_disabled_in": []
/// }
/// ```
///
/// Use `"..."` to add scopes without repeating the inherited list. In project
/// settings, it extends the user or parent configuration value. In
/// language-specific settings, it extends the scopes inherited by that
/// language. Omit `"..."` to replace the inherited list.
///
/// ```json
/// {
/// "edit_predictions_disabled_in": ["comment"],
/// "languages": {
/// "Go": {
/// "edit_predictions_disabled_in": ["string", "..."]
/// }
/// }
/// }
/// ```
///
/// Inherited scopes are inserted at `"..."`, and duplicates keep their first
/// occurrence.
///
/// Set `[]` to clear the inherited list. Omit this setting to inherit it unchanged.
pub edit_predictions_disabled_in: Option<SplicingVec>,
/// Whether to show tabs and spaces in the editor.
pub show_whitespaces: Option<ShowWhitespaceSetting>,
/// Visible characters used to render whitespace when show_whitespaces is enabled.
+1 -1
View File
@@ -11188,7 +11188,7 @@ fn edit_prediction_language_settings_section() -> [SettingsPageItem; 5] {
}),
SettingsPageItem::SettingItem(SettingItem {
title: "Disable in Language Scopes",
description: "Controls whether edit predictions are shown in the given language scopes.",
description: "Disable edit predictions in these language scopes, such as \"comment\" and \"string\". Use \"...\" to add scopes without repeating the inherited list.",
field: Box::new(
SettingField {
organization_override: None,
+10 -19
View File
@@ -898,42 +898,33 @@ See [Configuring the Prediction Debounce](../ai/edit-prediction.md#configuring-t
## Edit Predictions Disabled in
- Description: A list of language scopes in which edit predictions should be disabled.
- Setting: `edit_predictions_disabled_in`
- Default: `[]`
**Options**
List of `string` values
1. Don't show edit predictions in comments:
- Description: Disable edit predictions in these language scopes, such as "comment" and "string".
- Default:
```json [settings]
{
"edit_predictions_disabled_in": ["comment"]
"edit_predictions_disabled_in": []
}
```
2. Don't show edit predictions in strings and comments:
```json [settings]
{
"edit_predictions_disabled_in": ["comment", "string"]
}
```
3. Only in Go, don't show edit predictions in strings and comments:
Use `"..."` to add scopes without repeating the inherited list. In project settings, it extends the user or parent configuration value. In language-specific settings, it extends the scopes inherited by that language. Omit `"..."` to replace the inherited list.
```json [settings]
{
"edit_predictions_disabled_in": ["comment"],
"languages": {
"Go": {
"edit_predictions_disabled_in": ["comment", "string"]
"edit_predictions_disabled_in": ["string", "..."]
}
}
}
```
Inherited scopes are inserted at `"..."`, and duplicates keep their first occurrence.
Set `[]` to clear the inherited list. Omit this setting to inherit it unchanged.
## Current Line Highlight
- Description: How to highlight the current line in the editor.