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

@ -72,7 +72,7 @@ impl DraggedSelection {
}
#[derive(Clone, Copy, PartialEq, Debug, Deserialize, JsonSchema)]
#[serde(rename_all = "camelCase")]
#[serde(rename_all = "snake_case")]
pub enum SaveIntent {
/// write all files (even if unchanged)
/// prompt before overwriting on-disk changes
@ -96,13 +96,13 @@ pub enum SaveIntent {
pub struct ActivateItem(pub usize);
#[derive(Clone, PartialEq, Debug, Deserialize, JsonSchema, Default)]
#[serde(rename_all = "camelCase")]
#[serde(deny_unknown_fields)]
pub struct CloseActiveItem {
pub save_intent: Option<SaveIntent>,
}
#[derive(Clone, PartialEq, Debug, Deserialize, JsonSchema, Default)]
#[serde(rename_all = "camelCase")]
#[serde(deny_unknown_fields)]
pub struct CloseInactiveItems {
pub save_intent: Option<SaveIntent>,
#[serde(default)]
@ -110,7 +110,7 @@ pub struct CloseInactiveItems {
}
#[derive(Clone, PartialEq, Debug, Deserialize, JsonSchema, Default)]
#[serde(rename_all = "camelCase")]
#[serde(deny_unknown_fields)]
pub struct CloseAllItems {
pub save_intent: Option<SaveIntent>,
#[serde(default)]
@ -118,34 +118,35 @@ pub struct CloseAllItems {
}
#[derive(Clone, PartialEq, Debug, Deserialize, JsonSchema, Default)]
#[serde(rename_all = "camelCase")]
#[serde(deny_unknown_fields)]
pub struct CloseCleanItems {
#[serde(default)]
pub close_pinned: bool,
}
#[derive(Clone, PartialEq, Debug, Deserialize, JsonSchema, Default)]
#[serde(rename_all = "camelCase")]
#[serde(deny_unknown_fields)]
pub struct CloseItemsToTheRight {
#[serde(default)]
pub close_pinned: bool,
}
#[derive(Clone, PartialEq, Debug, Deserialize, JsonSchema, Default)]
#[serde(rename_all = "camelCase")]
#[serde(deny_unknown_fields)]
pub struct CloseItemsToTheLeft {
#[serde(default)]
pub close_pinned: bool,
}
#[derive(Clone, PartialEq, Debug, Deserialize, JsonSchema, Default)]
#[serde(rename_all = "camelCase")]
#[serde(deny_unknown_fields)]
pub struct RevealInProjectPanel {
#[serde(skip)]
pub entry_id: Option<u64>,
}
#[derive(Clone, PartialEq, Debug, Deserialize, JsonSchema, Default)]
#[serde(deny_unknown_fields)]
pub struct DeploySearch {
#[serde(default)]
pub replace_enabled: bool,

View file

@ -725,6 +725,7 @@ impl PaneAxis {
}
#[derive(Clone, Copy, Debug, Deserialize, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum SplitDirection {
Up,
Down,
@ -807,14 +808,6 @@ impl SplitDirection {
}
}
#[derive(Clone, Copy, Debug, Deserialize, JsonSchema, PartialEq)]
pub enum ResizeIntent {
Lengthen,
Shorten,
Widen,
Narrow,
}
mod element {
use std::mem;
use std::{cell::RefCell, iter, rc::Rc, sync::Arc};

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);
}))