Fix code actions migration (#40303)

Closes #40270

Release Notes:

- Fixed an issue with the settings migration to flatten `code_actions`
format steps where comments would cause enabled code actions to be
omitted from the migrated settings. If you were effected, restoring the
settings file backup and allowing the migration to re-run will result in
a valid settings file
- Fixed an issue where automated settings and keymap file updates would
occasionally assume 4-space indentation
This commit is contained in:
Ben Kunkle
2025-10-16 09:13:34 -04:00
committed by GitHub
parent c37a2f885a
commit ea6853d35c
10 changed files with 786 additions and 538 deletions
+7 -7
View File
@@ -23,7 +23,9 @@ use gpui::{
use language::{Language, LanguageConfig, ToOffset as _};
use notifications::status_toast::{StatusToast, ToastIcon};
use project::{CompletionDisplayOptions, Project};
use settings::{BaseKeymap, KeybindSource, KeymapFile, Settings as _, SettingsAssets};
use settings::{
BaseKeymap, KeybindSource, KeymapFile, Settings as _, SettingsAssets, infer_json_indent_size,
};
use ui::{
ActiveTheme as _, App, Banner, BorrowAppContext, ContextMenu, IconButtonShape, Indicator,
Modal, ModalFooter, ModalHeader, ParentElement as _, PopoverMenu, Render, Section,
@@ -1198,13 +1200,12 @@ impl KeymapEditor {
else {
return;
};
let tab_size = cx.global::<settings::SettingsStore>().json_tab_size();
self.previous_edit = Some(PreviousEdit::ScrollBarOffset(
self.table_interaction_state.read(cx).scroll_offset(),
));
let keyboard_mapper = cx.keyboard_mapper().clone();
cx.spawn(async move |_, _| {
remove_keybinding(to_remove, &fs, tab_size, keyboard_mapper.as_ref()).await
remove_keybinding(to_remove, &fs, keyboard_mapper.as_ref()).await
})
.detach_and_notify_err(window, cx);
}
@@ -2288,7 +2289,6 @@ impl KeybindingEditorModal {
fn save(&mut self, cx: &mut Context<Self>) -> Result<(), InputError> {
let existing_keybind = self.editing_keybind.clone();
let fs = self.fs.clone();
let tab_size = cx.global::<settings::SettingsStore>().json_tab_size();
let mut new_keystrokes = self.validate_keystrokes(cx).map_err(InputError::error)?;
new_keystrokes
@@ -2367,7 +2367,6 @@ impl KeybindingEditorModal {
&action_mapping,
new_action_args.as_deref(),
&fs,
tab_size,
keyboard_mapper.as_ref(),
)
.await
@@ -3019,13 +3018,14 @@ async fn save_keybinding_update(
action_mapping: &ActionMapping,
new_args: Option<&str>,
fs: &Arc<dyn Fs>,
tab_size: usize,
keyboard_mapper: &dyn PlatformKeyboardMapper,
) -> anyhow::Result<()> {
let keymap_contents = settings::KeymapFile::load_keymap_file(fs)
.await
.context("Failed to load keymap file")?;
let tab_size = infer_json_indent_size(&keymap_contents);
let existing_keystrokes = existing.keystrokes().unwrap_or_default();
let existing_context = existing.context().and_then(KeybindContextString::local_str);
let existing_args = existing
@@ -3089,7 +3089,6 @@ async fn save_keybinding_update(
async fn remove_keybinding(
existing: ProcessedBinding,
fs: &Arc<dyn Fs>,
tab_size: usize,
keyboard_mapper: &dyn PlatformKeyboardMapper,
) -> anyhow::Result<()> {
let Some(keystrokes) = existing.keystrokes() else {
@@ -3098,6 +3097,7 @@ async fn remove_keybinding(
let keymap_contents = settings::KeymapFile::load_keymap_file(fs)
.await
.context("Failed to load keymap file")?;
let tab_size = infer_json_indent_size(&keymap_contents);
let operation = settings::KeybindUpdateOperation::Remove {
target: settings::KeybindUpdateTarget {