Add workspace::ToggleEditPrediction
for toggling inline completions globally (#35418)
Closes: https://github.com/zed-industries/zed/issues/23704 Existing action is `editor::ToggleEditPrediction` ("This Buffer"). This action is `workspace::ToggleEditPredction` ("All Files"). You can add a custom keybind wi shortcut with: ```json { "context": "Workspace", "bindings": { "ctrl-alt-cmd-e": "workspace::ToggleEditPrediction" } }, ``` <img width="212" height="439" alt="Screenshot 2025-07-31 at 12 52 19" src="https://github.com/user-attachments/assets/15879daa-7d4d-4308-ab2b-5e78507f2fa5" /> Release Notes: - Added `workspace::ToggleEditPrediction` action for toggling `show_edit_predictions` in settings (Edit Predictions menu -> All Files).
This commit is contained in:
parent
497252480c
commit
5b40b3618f
2 changed files with 35 additions and 20 deletions
|
@ -2,11 +2,7 @@ use anyhow::Result;
|
||||||
use client::{UserStore, zed_urls};
|
use client::{UserStore, zed_urls};
|
||||||
use cloud_llm_client::UsageLimit;
|
use cloud_llm_client::UsageLimit;
|
||||||
use copilot::{Copilot, Status};
|
use copilot::{Copilot, Status};
|
||||||
use editor::{
|
use editor::{Editor, SelectionEffects, actions::ShowEditPrediction, scroll::Autoscroll};
|
||||||
Editor, SelectionEffects,
|
|
||||||
actions::{ShowEditPrediction, ToggleEditPrediction},
|
|
||||||
scroll::Autoscroll,
|
|
||||||
};
|
|
||||||
use feature_flags::{FeatureFlagAppExt, PredictEditsRateCompletionsFeatureFlag};
|
use feature_flags::{FeatureFlagAppExt, PredictEditsRateCompletionsFeatureFlag};
|
||||||
use fs::Fs;
|
use fs::Fs;
|
||||||
use gpui::{
|
use gpui::{
|
||||||
|
@ -441,9 +437,13 @@ impl EditPredictionButton {
|
||||||
if let Some(editor_focus_handle) = self.editor_focus_handle.clone() {
|
if let Some(editor_focus_handle) = self.editor_focus_handle.clone() {
|
||||||
let entry = ContextMenuEntry::new("This Buffer")
|
let entry = ContextMenuEntry::new("This Buffer")
|
||||||
.toggleable(IconPosition::Start, self.editor_show_predictions)
|
.toggleable(IconPosition::Start, self.editor_show_predictions)
|
||||||
.action(Box::new(ToggleEditPrediction))
|
.action(Box::new(editor::actions::ToggleEditPrediction))
|
||||||
.handler(move |window, cx| {
|
.handler(move |window, cx| {
|
||||||
editor_focus_handle.dispatch_action(&ToggleEditPrediction, window, cx);
|
editor_focus_handle.dispatch_action(
|
||||||
|
&editor::actions::ToggleEditPrediction,
|
||||||
|
window,
|
||||||
|
cx,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
match language_state.clone() {
|
match language_state.clone() {
|
||||||
|
@ -478,10 +478,13 @@ impl EditPredictionButton {
|
||||||
let settings = AllLanguageSettings::get_global(cx);
|
let settings = AllLanguageSettings::get_global(cx);
|
||||||
|
|
||||||
let globally_enabled = settings.show_edit_predictions(None, cx);
|
let globally_enabled = settings.show_edit_predictions(None, cx);
|
||||||
menu = menu.toggleable_entry("All Files", globally_enabled, IconPosition::Start, None, {
|
let entry = ContextMenuEntry::new("All Files")
|
||||||
let fs = fs.clone();
|
.toggleable(IconPosition::Start, globally_enabled)
|
||||||
move |_, cx| toggle_edit_predictions_globally(fs.clone(), cx)
|
.action(workspace::ToggleEditPrediction.boxed_clone())
|
||||||
});
|
.handler(|window, cx| {
|
||||||
|
window.dispatch_action(workspace::ToggleEditPrediction.boxed_clone(), cx)
|
||||||
|
});
|
||||||
|
menu = menu.item(entry);
|
||||||
|
|
||||||
let provider = settings.edit_predictions.provider;
|
let provider = settings.edit_predictions.provider;
|
||||||
let current_mode = settings.edit_predictions_mode();
|
let current_mode = settings.edit_predictions_mode();
|
||||||
|
@ -943,13 +946,6 @@ async fn open_disabled_globs_setting_in_editor(
|
||||||
anyhow::Ok(())
|
anyhow::Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn toggle_edit_predictions_globally(fs: Arc<dyn Fs>, cx: &mut App) {
|
|
||||||
let show_edit_predictions = all_language_settings(None, cx).show_edit_predictions(None, cx);
|
|
||||||
update_settings_file::<AllLanguageSettings>(fs, cx, move |file, _| {
|
|
||||||
file.defaults.show_edit_predictions = Some(!show_edit_predictions)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
fn set_completion_provider(fs: Arc<dyn Fs>, cx: &mut App, provider: EditPredictionProvider) {
|
fn set_completion_provider(fs: Arc<dyn Fs>, cx: &mut App, provider: EditPredictionProvider) {
|
||||||
update_settings_file::<AllLanguageSettings>(fs, cx, move |file, _| {
|
update_settings_file::<AllLanguageSettings>(fs, cx, move |file, _| {
|
||||||
file.features
|
file.features
|
||||||
|
|
|
@ -48,7 +48,10 @@ pub use item::{
|
||||||
ProjectItem, SerializableItem, SerializableItemHandle, WeakItemHandle,
|
ProjectItem, SerializableItem, SerializableItemHandle, WeakItemHandle,
|
||||||
};
|
};
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use language::{Buffer, LanguageRegistry, Rope};
|
use language::{
|
||||||
|
Buffer, LanguageRegistry, Rope,
|
||||||
|
language_settings::{AllLanguageSettings, all_language_settings},
|
||||||
|
};
|
||||||
pub use modal_layer::*;
|
pub use modal_layer::*;
|
||||||
use node_runtime::NodeRuntime;
|
use node_runtime::NodeRuntime;
|
||||||
use notifications::{
|
use notifications::{
|
||||||
|
@ -74,7 +77,7 @@ use remote::{SshClientDelegate, SshConnectionOptions, ssh_session::ConnectionIde
|
||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use session::AppSession;
|
use session::AppSession;
|
||||||
use settings::Settings;
|
use settings::{Settings, update_settings_file};
|
||||||
use shared_screen::SharedScreen;
|
use shared_screen::SharedScreen;
|
||||||
use sqlez::{
|
use sqlez::{
|
||||||
bindable::{Bind, Column, StaticColumnCount},
|
bindable::{Bind, Column, StaticColumnCount},
|
||||||
|
@ -233,6 +236,8 @@ actions!(
|
||||||
ToggleBottomDock,
|
ToggleBottomDock,
|
||||||
/// Toggles centered layout mode.
|
/// Toggles centered layout mode.
|
||||||
ToggleCenteredLayout,
|
ToggleCenteredLayout,
|
||||||
|
/// Toggles edit prediction feature globally for all files.
|
||||||
|
ToggleEditPrediction,
|
||||||
/// Toggles the left dock.
|
/// Toggles the left dock.
|
||||||
ToggleLeftDock,
|
ToggleLeftDock,
|
||||||
/// Toggles the right dock.
|
/// Toggles the right dock.
|
||||||
|
@ -5546,6 +5551,7 @@ impl Workspace {
|
||||||
.on_action(cx.listener(Self::activate_pane_at_index))
|
.on_action(cx.listener(Self::activate_pane_at_index))
|
||||||
.on_action(cx.listener(Self::move_item_to_pane_at_index))
|
.on_action(cx.listener(Self::move_item_to_pane_at_index))
|
||||||
.on_action(cx.listener(Self::move_focused_panel_to_next_position))
|
.on_action(cx.listener(Self::move_focused_panel_to_next_position))
|
||||||
|
.on_action(cx.listener(Self::toggle_edit_predictions_all_files))
|
||||||
.on_action(cx.listener(|workspace, _: &Unfollow, window, cx| {
|
.on_action(cx.listener(|workspace, _: &Unfollow, window, cx| {
|
||||||
let pane = workspace.active_pane().clone();
|
let pane = workspace.active_pane().clone();
|
||||||
workspace.unfollow_in_pane(&pane, window, cx);
|
workspace.unfollow_in_pane(&pane, window, cx);
|
||||||
|
@ -5977,6 +5983,19 @@ impl Workspace {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn toggle_edit_predictions_all_files(
|
||||||
|
&mut self,
|
||||||
|
_: &ToggleEditPrediction,
|
||||||
|
_window: &mut Window,
|
||||||
|
cx: &mut Context<Self>,
|
||||||
|
) {
|
||||||
|
let fs = self.project().read(cx).fs().clone();
|
||||||
|
let show_edit_predictions = all_language_settings(None, cx).show_edit_predictions(None, cx);
|
||||||
|
update_settings_file::<AllLanguageSettings>(fs, cx, move |file, _| {
|
||||||
|
file.defaults.show_edit_predictions = Some(!show_edit_predictions)
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn leader_border_for_pane(
|
fn leader_border_for_pane(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue