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

@ -170,12 +170,7 @@ pub struct OpenPaths {
pub struct ActivatePane(pub usize);
#[derive(Clone, Deserialize, PartialEq, JsonSchema)]
pub struct ActivatePaneInDirection(pub SplitDirection);
#[derive(Clone, Deserialize, PartialEq, JsonSchema)]
pub struct SwapPaneInDirection(pub SplitDirection);
#[derive(Clone, Deserialize, PartialEq, JsonSchema)]
#[serde(deny_unknown_fields)]
pub struct MoveItemToPane {
pub destination: usize,
#[serde(default = "default_true")]
@ -183,6 +178,7 @@ pub struct MoveItemToPane {
}
#[derive(Clone, Deserialize, PartialEq, JsonSchema)]
#[serde(deny_unknown_fields)]
pub struct MoveItemToPaneInDirection {
pub direction: SplitDirection,
#[serde(default = "default_true")]
@ -190,25 +186,25 @@ pub struct MoveItemToPaneInDirection {
}
#[derive(Clone, PartialEq, Debug, Deserialize, JsonSchema)]
#[serde(rename_all = "camelCase")]
#[serde(deny_unknown_fields)]
pub struct SaveAll {
pub save_intent: Option<SaveIntent>,
}
#[derive(Clone, PartialEq, Debug, Deserialize, JsonSchema)]
#[serde(rename_all = "camelCase")]
#[serde(deny_unknown_fields)]
pub struct Save {
pub save_intent: Option<SaveIntent>,
}
#[derive(Clone, PartialEq, Debug, Deserialize, Default, JsonSchema)]
#[serde(rename_all = "camelCase")]
#[serde(deny_unknown_fields)]
pub struct CloseAllItemsAndPanes {
pub save_intent: Option<SaveIntent>,
}
#[derive(Clone, PartialEq, Debug, Deserialize, Default, JsonSchema)]
#[serde(rename_all = "camelCase")]
#[serde(deny_unknown_fields)]
pub struct CloseInactiveTabsAndPanes {
pub save_intent: Option<SaveIntent>,
}
@ -217,6 +213,7 @@ pub struct CloseInactiveTabsAndPanes {
pub struct SendKeystrokes(pub String);
#[derive(Clone, Deserialize, PartialEq, Default, JsonSchema)]
#[serde(deny_unknown_fields)]
pub struct Reload {
pub binary_path: Option<PathBuf>,
}
@ -235,7 +232,6 @@ impl_actions!(
workspace,
[
ActivatePane,
ActivatePaneInDirection,
CloseAllItemsAndPanes,
CloseInactiveTabsAndPanes,
MoveItemToPane,
@ -244,11 +240,24 @@ impl_actions!(
Reload,
Save,
SaveAll,
SwapPaneInDirection,
SendKeystrokes,
]
);
actions!(
workspace,
[
ActivatePaneLeft,
ActivatePaneRight,
ActivatePaneUp,
ActivatePaneDown,
SwapPaneLeft,
SwapPaneRight,
SwapPaneUp,
SwapPaneDown,
]
);
#[derive(PartialEq, Eq, Debug)]
pub enum CloseIntent {
/// Quit the program entirely.
@ -301,6 +310,7 @@ impl PartialEq for Toast {
}
#[derive(Debug, Default, Clone, Deserialize, PartialEq, JsonSchema)]
#[serde(deny_unknown_fields)]
pub struct OpenTerminal {
pub working_directory: PathBuf,
}
@ -4821,29 +4831,38 @@ impl Workspace {
workspace.activate_previous_window(cx)
}),
)
.on_action(
cx.listener(|workspace, action: &ActivatePaneInDirection, window, cx| {
workspace.activate_pane_in_direction(action.0, window, cx)
}),
)
.on_action(cx.listener(|workspace, _: &ActivatePaneLeft, window, cx| {
workspace.activate_pane_in_direction(SplitDirection::Left, window, cx)
}))
.on_action(cx.listener(|workspace, _: &ActivatePaneRight, window, cx| {
workspace.activate_pane_in_direction(SplitDirection::Right, window, cx)
}))
.on_action(cx.listener(|workspace, _: &ActivatePaneUp, window, cx| {
workspace.activate_pane_in_direction(SplitDirection::Up, window, cx)
}))
.on_action(cx.listener(|workspace, _: &ActivatePaneDown, window, cx| {
workspace.activate_pane_in_direction(SplitDirection::Down, window, cx)
}))
.on_action(cx.listener(|workspace, _: &ActivateNextPane, window, cx| {
workspace.activate_next_pane(window, cx)
}))
.on_action(
cx.listener(|workspace, action: &ActivatePaneInDirection, window, cx| {
workspace.activate_pane_in_direction(action.0, window, cx)
}),
)
.on_action(cx.listener(
|workspace, action: &MoveItemToPaneInDirection, window, cx| {
workspace.move_item_to_pane_in_direction(action, window, cx)
},
))
.on_action(
cx.listener(|workspace, action: &SwapPaneInDirection, _, cx| {
workspace.swap_pane_in_direction(action.0, cx)
}),
)
.on_action(cx.listener(|workspace, _: &SwapPaneLeft, _, cx| {
workspace.swap_pane_in_direction(SplitDirection::Left, cx)
}))
.on_action(cx.listener(|workspace, _: &SwapPaneRight, _, cx| {
workspace.swap_pane_in_direction(SplitDirection::Right, cx)
}))
.on_action(cx.listener(|workspace, _: &SwapPaneUp, _, cx| {
workspace.swap_pane_in_direction(SplitDirection::Up, cx)
}))
.on_action(cx.listener(|workspace, _: &SwapPaneDown, _, cx| {
workspace.swap_pane_in_direction(SplitDirection::Down, cx)
}))
.on_action(cx.listener(|this, _: &ToggleLeftDock, window, cx| {
this.toggle_dock(DockPosition::Left, window, cx);
}))