Migrate keymap and settings + edit predictions rename (#23834)

- [x] snake case keymap properties
- [x] flatten actions
- [x] keymap migration + notfication
- [x] settings migration + notification
- [x] inline completions -> edit predictions 

### future: 
- keymap notification doesn't show up on start up, only on keymap save.
this is existing bug in zed, will be addressed in seperate PR.

Release Notes:

- Added a notification for deprecated settings and keymaps, allowing you
to migrate them with a single click. A backup of your existing keymap
and settings will be created in your home directory.
- Modified some keymap actions and settings for consistency.

---------

Co-authored-by: Piotr Osiewicz <piotr@zed.dev>
Co-authored-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
This commit is contained in:
smit 2025-02-07 21:17:07 +05:30 committed by GitHub
parent a1544f47ad
commit 00c2a30059
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
58 changed files with 2106 additions and 617 deletions

View file

@ -1,7 +1,7 @@
use anyhow::Result;
use client::UserStore;
use copilot::{Copilot, Status};
use editor::{actions::ShowInlineCompletion, scroll::Autoscroll, Editor};
use editor::{actions::ShowEditPrediction, scroll::Autoscroll, Editor};
use feature_flags::{
FeatureFlagAppExt, PredictEditsFeatureFlag, PredictEditsRateCompletionsFeatureFlag,
};
@ -13,9 +13,7 @@ use gpui::{
};
use indoc::indoc;
use language::{
language_settings::{
self, all_language_settings, AllLanguageSettings, InlineCompletionProvider,
},
language_settings::{self, all_language_settings, AllLanguageSettings, EditPredictionProvider},
File, Language,
};
use regex::Regex;
@ -37,7 +35,7 @@ use zed_actions::OpenBrowser;
use zeta::RateCompletionModal;
actions!(zeta, [RateCompletions]);
actions!(inline_completion, [ToggleMenu]);
actions!(edit_prediction, [ToggleMenu]);
const COPILOT_SETTINGS_URL: &str = "https://github.com/settings/copilot";
@ -49,7 +47,7 @@ pub struct InlineCompletionButton {
editor_focus_handle: Option<FocusHandle>,
language: Option<Arc<Language>>,
file: Option<Arc<dyn File>>,
inline_completion_provider: Option<Arc<dyn inline_completion::InlineCompletionProviderHandle>>,
edit_prediction_provider: Option<Arc<dyn inline_completion::InlineCompletionProviderHandle>>,
fs: Arc<dyn Fs>,
workspace: WeakEntity<Workspace>,
user_store: Entity<UserStore>,
@ -67,10 +65,10 @@ impl Render for InlineCompletionButton {
fn render(&mut self, _: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
let all_language_settings = all_language_settings(None, cx);
match all_language_settings.inline_completions.provider {
InlineCompletionProvider::None => div(),
match all_language_settings.edit_predictions.provider {
EditPredictionProvider::None => div(),
InlineCompletionProvider::Copilot => {
EditPredictionProvider::Copilot => {
let Some(copilot) = Copilot::global(cx) else {
return div();
};
@ -146,7 +144,7 @@ impl Render for InlineCompletionButton {
)
}
InlineCompletionProvider::Supermaven => {
EditPredictionProvider::Supermaven => {
let Some(supermaven) = Supermaven::global(cx) else {
return div();
};
@ -196,7 +194,7 @@ impl Render for InlineCompletionButton {
set_completion_provider(
fs.clone(),
cx,
InlineCompletionProvider::Copilot,
EditPredictionProvider::Copilot,
)
},
)
@ -226,7 +224,7 @@ impl Render for InlineCompletionButton {
);
}
InlineCompletionProvider::Zed => {
EditPredictionProvider::Zed => {
if !cx.has_flag::<PredictEditsFeatureFlag>() {
return div();
}
@ -307,7 +305,7 @@ impl Render for InlineCompletionButton {
.with_handle(self.popover_menu_handle.clone());
let is_refreshing = self
.inline_completion_provider
.edit_prediction_provider
.as_ref()
.map_or(false, |provider| provider.is_refreshing(cx));
@ -352,7 +350,7 @@ impl InlineCompletionButton {
editor_focus_handle: None,
language: None,
file: None,
inline_completion_provider: None,
edit_prediction_provider: None,
popover_menu_handle,
workspace,
fs,
@ -375,11 +373,7 @@ impl InlineCompletionButton {
.entry("Use Supermaven", None, {
let fs = fs.clone();
move |_window, cx| {
set_completion_provider(
fs.clone(),
cx,
InlineCompletionProvider::Supermaven,
)
set_completion_provider(fs.clone(), cx, EditPredictionProvider::Supermaven)
}
})
})
@ -394,7 +388,7 @@ impl InlineCompletionButton {
let fs = fs.clone();
let language_enabled =
language_settings::language_settings(Some(language.name()), None, cx)
.show_inline_completions;
.show_edit_predictions;
menu = menu.toggleable_entry(
language.name(),
@ -418,7 +412,7 @@ impl InlineCompletionButton {
);
menu = menu.separator().header("Privacy Settings");
if let Some(provider) = &self.inline_completion_provider {
if let Some(provider) = &self.edit_prediction_provider {
let data_collection = provider.data_collection_state(cx);
if data_collection.is_supported() {
let provider = provider.clone();
@ -491,12 +485,12 @@ impl InlineCompletionButton {
.separator()
.entry(
"Predict Edit at Cursor",
Some(Box::new(ShowInlineCompletion)),
Some(Box::new(ShowEditPrediction)),
{
let editor_focus_handle = editor_focus_handle.clone();
move |window, cx| {
editor_focus_handle.dispatch_action(&ShowInlineCompletion, window, cx);
editor_focus_handle.dispatch_action(&ShowEditPrediction, window, cx);
}
},
)
@ -579,7 +573,7 @@ impl InlineCompletionButton {
.unwrap_or(true),
)
};
self.inline_completion_provider = editor.inline_completion_provider();
self.edit_prediction_provider = editor.edit_prediction_provider();
self.language = language.cloned();
self.file = file;
self.editor_focus_handle = Some(editor.focus_handle(cx));
@ -664,7 +658,7 @@ async fn open_disabled_globs_setting_in_editor(
// Ensure that we always have "inline_completions { "disabled_globs": [] }"
let edits = settings.edits_for_update::<AllLanguageSettings>(&text, |file| {
file.inline_completions
file.edit_predictions
.get_or_insert_with(Default::default)
.disabled_globs
.get_or_insert_with(Vec::new);
@ -696,17 +690,17 @@ async fn open_disabled_globs_setting_in_editor(
}
fn toggle_inline_completions_globally(fs: Arc<dyn Fs>, cx: &mut App) {
let show_inline_completions = all_language_settings(None, cx).show_inline_completions(None, cx);
let show_edit_predictions = all_language_settings(None, cx).show_inline_completions(None, cx);
update_settings_file::<AllLanguageSettings>(fs, cx, move |file, _| {
file.defaults.show_inline_completions = Some(!show_inline_completions)
file.defaults.show_edit_predictions = Some(!show_edit_predictions)
});
}
fn set_completion_provider(fs: Arc<dyn Fs>, cx: &mut App, provider: InlineCompletionProvider) {
fn set_completion_provider(fs: Arc<dyn Fs>, cx: &mut App, provider: EditPredictionProvider) {
update_settings_file::<AllLanguageSettings>(fs, cx, move |file, _| {
file.features
.get_or_insert(Default::default())
.inline_completion_provider = Some(provider);
.edit_prediction_provider = Some(provider);
});
}
@ -715,13 +709,13 @@ fn toggle_show_inline_completions_for_language(
fs: Arc<dyn Fs>,
cx: &mut App,
) {
let show_inline_completions =
let show_edit_predictions =
all_language_settings(None, cx).show_inline_completions(Some(&language), cx);
update_settings_file::<AllLanguageSettings>(fs, cx, move |file, _| {
file.languages
.entry(language.name())
.or_default()
.show_inline_completions = Some(!show_inline_completions);
.show_edit_predictions = Some(!show_edit_predictions);
});
}
@ -729,6 +723,6 @@ fn hide_copilot(fs: Arc<dyn Fs>, cx: &mut App) {
update_settings_file::<AllLanguageSettings>(fs, cx, move |file, _| {
file.features
.get_or_insert(Default::default())
.inline_completion_provider = Some(InlineCompletionProvider::None);
.edit_prediction_provider = Some(EditPredictionProvider::None);
});
}