From 8ed642dc1673c6b4d9da0f6ce268724b652fb553 Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Mon, 11 Dec 2023 11:00:55 -0700 Subject: [PATCH] Clear out easy todo!()s --- crates/vim2/src/command.rs | 3 +-- crates/vim2/src/editor_events.rs | 6 ------ crates/vim2/src/vim.rs | 36 ++++++++++++++++---------------- crates/zed2/src/app_menus.rs | 4 +++- crates/zed2/src/zed2.rs | 3 +-- crates/zed_actions2/src/lib.rs | 4 +++- 6 files changed, 26 insertions(+), 30 deletions(-) diff --git a/crates/vim2/src/command.rs b/crates/vim2/src/command.rs index 718d4097a45bb25e7631e2b4fea5065c824adb16..459b3c48975971c259796569ef09886e0d13078a 100644 --- a/crates/vim2/src/command.rs +++ b/crates/vim2/src/command.rs @@ -167,8 +167,7 @@ pub fn command_interceptor(mut query: &str, _: &AppContext) -> Option { - // ("cquit!", zed_actions::Quit.boxed_clone()) - todo!(); // Quit is no longer in zed actions :/ + ("cquit!", zed_actions::Quit.boxed_clone()) } // pane management diff --git a/crates/vim2/src/editor_events.rs b/crates/vim2/src/editor_events.rs index a6c3378d4790f662a2ca32a3015c6fbe7035a3b8..b915bd779ec1df85624aab7c40551b3a353a6d55 100644 --- a/crates/vim2/src/editor_events.rs +++ b/crates/vim2/src/editor_events.rs @@ -29,12 +29,6 @@ fn focused(editor: View, cx: &mut WindowContext) { Vim::update(cx, |vim, cx| { vim.set_active_editor(editor.clone(), cx); - if vim.enabled { - // todo!() - // cx.emit_global(VimEvent::ModeChanged { - // mode: vim.state().mode, - // }); - } }); } diff --git a/crates/vim2/src/vim.rs b/crates/vim2/src/vim.rs index c70decf5c3b8feb52bb78d922e77ebe189b35eb6..d6bce1a976f13654a47c9d767e8ff8c6aeea365c 100644 --- a/crates/vim2/src/vim.rs +++ b/crates/vim2/src/vim.rs @@ -326,9 +326,6 @@ impl Vim { self.take_count(cx); } - // todo!() - // cx.emit_global(VimEvent::ModeChanged { mode }); - // Sync editor settings like clip mode self.sync_vim_settings(cx); @@ -495,21 +492,24 @@ impl Vim { let _ = cx.remove_global::(); } - // todo!(); - // cx.update_active_window(|cx| { - // if self.enabled { - // let active_editor = cx - // .root_view() - // .downcast_ref::() - // .and_then(|workspace| workspace.read(cx).active_item(cx)) - // .and_then(|item| item.downcast::()); - // if let Some(active_editor) = active_editor { - // self.set_active_editor(active_editor, cx); - // } - // self.switch_mode(Mode::Normal, false, cx); - // } - // self.sync_vim_settings(cx); - // }); + if let Some(active_window) = cx.active_window() { + active_window + .update(cx, |root_view, cx| { + if self.enabled { + let active_editor = root_view + .downcast::() + .ok() + .and_then(|workspace| workspace.read(cx).active_item(cx)) + .and_then(|item| item.downcast::()); + if let Some(active_editor) = active_editor { + self.set_active_editor(active_editor, cx); + } + self.switch_mode(Mode::Normal, false, cx); + } + self.sync_vim_settings(cx); + }) + .ok(); + } } } diff --git a/crates/zed2/src/app_menus.rs b/crates/zed2/src/app_menus.rs index 63db41e7bd5bc0f1a2fefb8fd80e4fc0f9738959..3763bc7d3021d347c5032816581f96290131a466 100644 --- a/crates/zed2/src/app_menus.rs +++ b/crates/zed2/src/app_menus.rs @@ -2,6 +2,8 @@ use gpui::{Menu, MenuItem, OsAction}; #[cfg(target_os = "macos")] pub fn app_menus() -> Vec> { + use zed_actions::Quit; + vec![ Menu { name: "Zed", @@ -25,7 +27,7 @@ pub fn app_menus() -> Vec> { MenuItem::action("Hide Zed", super::Hide), MenuItem::action("Hide Others", super::HideOthers), MenuItem::action("Show All", super::ShowAll), - MenuItem::action("Quit", super::Quit), + MenuItem::action("Quit", Quit), ], }, Menu { diff --git a/crates/zed2/src/zed2.rs b/crates/zed2/src/zed2.rs index be0dc6bb20f91948a90c71107a351b32b6ddb66a..7c8dd0c45e9b55dd9fe383598f4f433c15f1cb36 100644 --- a/crates/zed2/src/zed2.rs +++ b/crates/zed2/src/zed2.rs @@ -41,7 +41,7 @@ use workspace::{ notifications::simple_message_notification::MessageNotification, open_new, AppState, NewFile, NewWindow, Workspace, WorkspaceSettings, }; -use zed_actions::{OpenBrowser, OpenZedURL}; +use zed_actions::{OpenBrowser, OpenZedURL, Quit}; actions!( zed, @@ -61,7 +61,6 @@ actions!( OpenLog, OpenSettings, OpenTelemetryLog, - Quit, ResetBufferFontSize, ResetDatabase, ShowAll, diff --git a/crates/zed_actions2/src/lib.rs b/crates/zed_actions2/src/lib.rs index 91a935c1f2da257e856887a239087ce6cb571ddd..fa1a4a5ea961ce77ecd5d199a182c88c17166bbe 100644 --- a/crates/zed_actions2/src/lib.rs +++ b/crates/zed_actions2/src/lib.rs @@ -1,4 +1,4 @@ -use gpui::impl_actions; +use gpui::{actions, impl_actions}; use serde::Deserialize; // If the zed binary doesn't use anything in this crate, it will be optimized away @@ -21,3 +21,5 @@ pub struct OpenZedURL { } impl_actions!(zed, [OpenBrowser, OpenZedURL]); + +actions!(zed, [Quit]);