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:
parent
a1544f47ad
commit
00c2a30059
58 changed files with 2106 additions and 617 deletions
|
@ -1,19 +1,31 @@
|
|||
use gpui::{impl_actions, Entity, OwnedMenu, OwnedMenuItem};
|
||||
use gpui::{Entity, OwnedMenu, OwnedMenuItem};
|
||||
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
use gpui::{actions, impl_actions};
|
||||
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
use schemars::JsonSchema;
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
use serde::Deserialize;
|
||||
|
||||
use smallvec::SmallVec;
|
||||
use ui::{prelude::*, ContextMenu, PopoverMenu, PopoverMenuHandle, Tooltip};
|
||||
|
||||
impl_actions!(
|
||||
app_menu,
|
||||
[OpenApplicationMenu, NavigateApplicationMenuInDirection]
|
||||
);
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
impl_actions!(app_menu, [OpenApplicationMenu]);
|
||||
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
actions!(app_menu, [ActivateMenuRight, ActivateMenuLeft]);
|
||||
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
#[derive(Clone, Deserialize, JsonSchema, PartialEq, Default)]
|
||||
pub struct OpenApplicationMenu(String);
|
||||
|
||||
#[derive(Clone, Deserialize, JsonSchema, PartialEq, Default)]
|
||||
pub struct NavigateApplicationMenuInDirection(String);
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
pub enum ActivateDirection {
|
||||
Left,
|
||||
Right,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
struct MenuEntry {
|
||||
|
@ -190,7 +202,7 @@ impl ApplicationMenu {
|
|||
#[cfg(not(target_os = "macos"))]
|
||||
pub fn navigate_menus_in_direction(
|
||||
&mut self,
|
||||
action: &NavigateApplicationMenuInDirection,
|
||||
direction: ActivateDirection,
|
||||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
|
@ -202,22 +214,21 @@ impl ApplicationMenu {
|
|||
return;
|
||||
};
|
||||
|
||||
let next_index = match action.0.as_str() {
|
||||
"Left" => {
|
||||
let next_index = match direction {
|
||||
ActivateDirection::Left => {
|
||||
if current_index == 0 {
|
||||
self.entries.len() - 1
|
||||
} else {
|
||||
current_index - 1
|
||||
}
|
||||
}
|
||||
"Right" => {
|
||||
ActivateDirection::Right => {
|
||||
if current_index == self.entries.len() - 1 {
|
||||
0
|
||||
} else {
|
||||
current_index + 1
|
||||
}
|
||||
}
|
||||
_ => return,
|
||||
};
|
||||
|
||||
self.entries[current_index].handle.hide(cx);
|
||||
|
|
|
@ -9,7 +9,9 @@ mod stories;
|
|||
use crate::application_menu::ApplicationMenu;
|
||||
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
use crate::application_menu::{NavigateApplicationMenuInDirection, OpenApplicationMenu};
|
||||
use crate::application_menu::{
|
||||
ActivateDirection, ActivateMenuLeft, ActivateMenuRight, OpenApplicationMenu,
|
||||
};
|
||||
|
||||
use crate::platforms::{platform_linux, platform_mac, platform_windows};
|
||||
use auto_update::AutoUpdateStatus;
|
||||
|
@ -78,22 +80,36 @@ pub fn init(cx: &mut App) {
|
|||
});
|
||||
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
workspace.register_action(
|
||||
|workspace, action: &NavigateApplicationMenuInDirection, window, cx| {
|
||||
if let Some(titlebar) = workspace
|
||||
.titlebar_item()
|
||||
.and_then(|item| item.downcast::<TitleBar>().ok())
|
||||
{
|
||||
titlebar.update(cx, |titlebar, cx| {
|
||||
if let Some(ref menu) = titlebar.application_menu {
|
||||
menu.update(cx, |menu, cx| {
|
||||
menu.navigate_menus_in_direction(action, window, cx)
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
);
|
||||
workspace.register_action(|workspace, _: &ActivateMenuRight, window, cx| {
|
||||
if let Some(titlebar) = workspace
|
||||
.titlebar_item()
|
||||
.and_then(|item| item.downcast::<TitleBar>().ok())
|
||||
{
|
||||
titlebar.update(cx, |titlebar, cx| {
|
||||
if let Some(ref menu) = titlebar.application_menu {
|
||||
menu.update(cx, |menu, cx| {
|
||||
menu.navigate_menus_in_direction(ActivateDirection::Right, window, cx)
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
workspace.register_action(|workspace, _: &ActivateMenuLeft, window, cx| {
|
||||
if let Some(titlebar) = workspace
|
||||
.titlebar_item()
|
||||
.and_then(|item| item.downcast::<TitleBar>().ok())
|
||||
{
|
||||
titlebar.update(cx, |titlebar, cx| {
|
||||
if let Some(ref menu) = titlebar.application_menu {
|
||||
menu.update(cx, |menu, cx| {
|
||||
menu.navigate_menus_in_direction(ActivateDirection::Left, window, cx)
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
})
|
||||
.detach();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue