diff --git a/crates/settings_ui/src/keybindings.rs b/crates/settings_ui/src/keybindings.rs index fd70097e351004fd10191b04413fcccd94c84461..a15cbd3f55ffc8c68913573f615d6690e19da583 100644 --- a/crates/settings_ui/src/keybindings.rs +++ b/crates/settings_ui/src/keybindings.rs @@ -111,69 +111,6 @@ struct ProcessedKeybinding { context: SharedString, } -impl SerializableItem for KeymapEditor { - fn serialized_item_kind() -> &'static str { - "KeymapEditor" - } - - fn cleanup( - workspace_id: workspace::WorkspaceId, - alive_items: Vec, - _window: &mut Window, - cx: &mut App, - ) -> gpui::Task> { - workspace::delete_unloaded_items( - alive_items, - workspace_id, - "keybinding_editors", - &KEYBINDING_EDITORS, - cx, - ) - } - - fn deserialize( - _project: gpui::Entity, - _workspace: gpui::WeakEntity, - workspace_id: workspace::WorkspaceId, - item_id: workspace::ItemId, - _window: &mut Window, - cx: &mut App, - ) -> gpui::Task>> { - cx.spawn(async move |cx| { - if KEYBINDING_EDITORS - .get_keybinding_editor(item_id, workspace_id)? - .is_some() - { - cx.new(|cx| KeymapEditor::new(cx)) - } else { - Err(anyhow!("No keybinding editor to deserialize")) - } - }) - } - - fn serialize( - &mut self, - workspace: &mut Workspace, - item_id: workspace::ItemId, - _closing: bool, - _window: &mut Window, - cx: &mut ui::Context, - ) -> Option>> { - let Some(workspace_id) = workspace.database_id() else { - return None; - }; - Some(cx.background_spawn(async move { - KEYBINDING_EDITORS - .save_keybinding_editor(item_id, workspace_id) - .await - })) - } - - fn should_serialize(&self, _event: &Self::Event) -> bool { - false - } -} - impl Item for KeymapEditor { type Event = (); @@ -356,6 +293,69 @@ where } } +impl SerializableItem for KeymapEditor { + fn serialized_item_kind() -> &'static str { + "KeymapEditor" + } + + fn cleanup( + workspace_id: workspace::WorkspaceId, + alive_items: Vec, + _window: &mut Window, + cx: &mut App, + ) -> gpui::Task> { + workspace::delete_unloaded_items( + alive_items, + workspace_id, + "keybinding_editors", + &KEYBINDING_EDITORS, + cx, + ) + } + + fn deserialize( + _project: gpui::Entity, + _workspace: gpui::WeakEntity, + workspace_id: workspace::WorkspaceId, + item_id: workspace::ItemId, + _window: &mut Window, + cx: &mut App, + ) -> gpui::Task>> { + cx.spawn(async move |cx| { + if KEYBINDING_EDITORS + .get_keybinding_editor(item_id, workspace_id)? + .is_some() + { + cx.new(|cx| KeymapEditor::new(cx)) + } else { + Err(anyhow!("No keybinding editor to deserialize")) + } + }) + } + + fn serialize( + &mut self, + workspace: &mut Workspace, + item_id: workspace::ItemId, + _closing: bool, + _window: &mut Window, + cx: &mut ui::Context, + ) -> Option>> { + let Some(workspace_id) = workspace.database_id() else { + return None; + }; + Some(cx.background_spawn(async move { + KEYBINDING_EDITORS + .save_keybinding_editor(item_id, workspace_id) + .await + })) + } + + fn should_serialize(&self, _event: &Self::Event) -> bool { + false + } +} + mod persistence { use db::{define_connection, query, sqlez_macros::sql}; use workspace::WorkspaceDb;