mirror of
https://github.com/zed-industries/zed.git
synced 2026-11-19 06:59:22 +01:00
feat: config to toggle edit prediction button in the status bar (#66450)
## Summary Resolves https://github.com/zed-industries/zed/discussions/26095 https://github.com/user-attachments/assets/fca26dcc-e526-4e69-b611-4b3cdcc91066 ## Testing Manually test your changes; report results, mention platforms if relevant. How can reviewers test this easily? Include setup and steps. ## Self-review - [x] I've reviewed my diff for quality, security, reliability, and performance. - [x] UI changes follow the [checklist](https://zed.dev/docs/development/ui-checklist). - [ ] Tests cover the new or changed behavior. Release Notes: - Added an `edit_predictions.button` setting to toggle the edit prediction button in the status bar
This commit is contained in:
@@ -1932,6 +1932,8 @@
|
||||
// "load_direnv": "disabled"
|
||||
"load_direnv": "direct",
|
||||
"edit_predictions": {
|
||||
// Whether to show the edit prediction button in the status bar.
|
||||
"button": true,
|
||||
// Which edit prediction provider to use.
|
||||
"provider": "zed",
|
||||
// Disable edit predictions for files matching these glob patterns.
|
||||
|
||||
@@ -78,6 +78,10 @@ impl Render for EditPredictionButton {
|
||||
|
||||
let language_settings = all_language_settings(None, cx);
|
||||
|
||||
if !language_settings.edit_predictions.button {
|
||||
return div().hidden();
|
||||
}
|
||||
|
||||
match language_settings.edit_predictions.provider {
|
||||
EditPredictionProvider::Copilot => {
|
||||
let Some(copilot) = EditPredictionStore::try_global(cx)
|
||||
@@ -1480,10 +1484,14 @@ impl StatusItemView for EditPredictionButton {
|
||||
}
|
||||
|
||||
fn hide_setting(&self, _: &App) -> Option<HideStatusItem> {
|
||||
// This button is already gated on having a non-disabled edit
|
||||
// prediction provider, which the user manages through provider/AI
|
||||
// settings.
|
||||
None
|
||||
Some(HideStatusItem::new(|settings| {
|
||||
settings
|
||||
.project
|
||||
.all_languages
|
||||
.edit_predictions
|
||||
.get_or_insert_default()
|
||||
.button = Some(false);
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -497,6 +497,8 @@ impl InlayHintSettings {
|
||||
/// The settings for edit predictions, such as [GitHub Copilot](https://github.com/features/copilot).
|
||||
#[derive(Clone, Debug, Default)]
|
||||
pub struct EditPredictionSettings {
|
||||
/// Whether to show the edit prediction button in the status bar.
|
||||
pub button: bool,
|
||||
/// The provider that supplies edit predictions.
|
||||
pub provider: settings::EditPredictionProvider,
|
||||
/// Disable edit predictions for files matching these glob patterns.
|
||||
@@ -1030,6 +1032,7 @@ impl settings::Settings for AllLanguageSettings {
|
||||
|
||||
Self {
|
||||
edit_predictions: EditPredictionSettings {
|
||||
button: edit_predictions.button.unwrap(),
|
||||
provider: if let Some(provider) = edit_prediction_provider {
|
||||
provider
|
||||
} else {
|
||||
|
||||
@@ -131,6 +131,10 @@ impl EditPredictionProvider {
|
||||
#[with_fallible_options]
|
||||
#[derive(Clone, Debug, Default, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq)]
|
||||
pub struct EditPredictionSettingsContent {
|
||||
/// Whether to show the edit prediction button in the status bar.
|
||||
///
|
||||
/// Default: true
|
||||
pub button: Option<bool>,
|
||||
/// Determines which edit prediction provider to use.
|
||||
pub provider: Option<EditPredictionProvider>,
|
||||
/// Disable edit predictions for files matching these glob patterns.
|
||||
|
||||
@@ -4171,7 +4171,7 @@ fn search_and_files_page() -> SettingsPage {
|
||||
}
|
||||
|
||||
fn window_and_layout_page() -> SettingsPage {
|
||||
fn status_bar_section() -> [SettingsPageItem; 12] {
|
||||
fn status_bar_section() -> [SettingsPageItem; 13] {
|
||||
[
|
||||
SettingsPageItem::SectionHeader("Status Bar"),
|
||||
SettingsPageItem::SettingItem(SettingItem {
|
||||
@@ -4336,6 +4336,33 @@ fn window_and_layout_page() -> SettingsPage {
|
||||
metadata: None,
|
||||
files: USER,
|
||||
}),
|
||||
SettingsPageItem::SettingItem(SettingItem {
|
||||
title: "Edit Prediction Button",
|
||||
description: "Show the edit prediction button in the status bar.",
|
||||
field: Box::new(SettingField {
|
||||
organization_override: None,
|
||||
json_path: Some("edit_predictions.button"),
|
||||
pick: |settings_content| {
|
||||
settings_content
|
||||
.project
|
||||
.all_languages
|
||||
.edit_predictions
|
||||
.as_ref()?
|
||||
.button
|
||||
.as_ref()
|
||||
},
|
||||
write: |settings_content, value, _| {
|
||||
settings_content
|
||||
.project
|
||||
.all_languages
|
||||
.edit_predictions
|
||||
.get_or_insert_default()
|
||||
.button = value;
|
||||
},
|
||||
}),
|
||||
metadata: None,
|
||||
files: USER,
|
||||
}),
|
||||
SettingsPageItem::SettingItem(SettingItem {
|
||||
title: "Project Search Button",
|
||||
description: "Show the project search button in the status bar.",
|
||||
|
||||
@@ -938,6 +938,16 @@ Non-negative integer values representing milliseconds. Set this to `0` to disabl
|
||||
|
||||
See [Configuring the Prediction Debounce](../ai/edit-prediction.md#configuring-the-prediction-debounce) for more information.
|
||||
|
||||
### Edit Prediction Button
|
||||
|
||||
- Description: Whether to show the edit prediction button in the status bar. Hiding the button does not disable edit predictions.
|
||||
- Setting: `edit_predictions.button`
|
||||
- Default: `true`
|
||||
|
||||
**Options**
|
||||
|
||||
`boolean` values
|
||||
|
||||
## Edit Predictions Disabled in
|
||||
|
||||
- Setting: `edit_predictions_disabled_in`
|
||||
|
||||
Reference in New Issue
Block a user