Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
fix final failing tests
Kay Simmons2cf48c03f997
diff --git a/assets/keymaps/vim.json b/assets/keymaps/vim.jsonindex 5cdd4fc7d4c..99c94798db3 100644--- a/assets/keymaps/vim.json+++ b/assets/keymaps/vim.json@@ -8,6 +8,22 @@"Namespace": "G"}],+ "i": [+ "vim::PushOperator",+ {+ "Object": {+ "around": false+ }+ }+ ],+ "a": [+ "vim::PushOperator",+ {+ "Object": {+ "around": true+ }+ }+ ],"h": "vim::Left","backspace": "vim::Backspace","j": "vim::Down",@@ -77,28 +93,6 @@]}},- {- //Operators- "context": "Editor && VimControl && vim_operator == none",- "bindings": {- "i": [- "vim::PushOperator",- {- "Object": {- "around": false- }- }- ],- "a": [- "vim::PushOperator",- {- "Object": {- "around": true- }- }- ]- }- },{"context": "Editor && vim_mode == normal && vim_operator == none","bindings": {diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rsindex 1aee1e246dd..417b60bc5bb 100644--- a/crates/editor/src/editor.rs+++ b/crates/editor/src/editor.rs@@ -3709,18 +3709,30 @@ impl Editor {})}- pub fn move_page_up(&mut self, action: &MovePageUp, cx: &mut ViewContext<Self>) -> Option<()> {- self.take_rename(true, cx)?;- if self.context_menu.as_mut()?.select_first(cx) {- return None;+ pub fn move_page_up(&mut self, action: &MovePageUp, cx: &mut ViewContext<Self>) {+ if self.take_rename(true, cx).is_some() {+ return;+ }++ if self+ .context_menu+ .as_mut()+ .map(|menu| menu.select_first(cx))+ .unwrap_or(false)+ {+ return;}if matches!(self.mode, EditorMode::SingleLine) {cx.propagate_action();- return None;+ return;}- let row_count = self.visible_line_count()? as u32 - 1;+ let row_count = if let Some(row_count) = self.visible_line_count() {+ row_count as u32 - 1+ } else {+ return;+ };let autoscroll = if action.center_cursor {Autoscroll::center()@@ -3739,8 +3751,6 @@ impl Editor {selection.collapse_to(cursor, goal);});});-- Some(())}pub fn select_up(&mut self, _: &SelectUp, cx: &mut ViewContext<Self>) {@@ -3775,25 +3785,30 @@ impl Editor {});}- pub fn move_page_down(- &mut self,- action: &MovePageDown,- cx: &mut ViewContext<Self>,- ) -> Option<()> {+ pub fn move_page_down(&mut self, action: &MovePageDown, cx: &mut ViewContext<Self>) {if self.take_rename(true, cx).is_some() {- return None;+ return;}- if self.context_menu.as_mut()?.select_last(cx) {- return None;+ if self+ .context_menu+ .as_mut()+ .map(|menu| menu.select_last(cx))+ .unwrap_or(false)+ {+ return;}if matches!(self.mode, EditorMode::SingleLine) {cx.propagate_action();- return None;+ return;}- let row_count = self.visible_line_count()? as u32 - 1;+ let row_count = if let Some(row_count) = self.visible_line_count() {+ row_count as u32 - 1+ } else {+ return;+ };let autoscroll = if action.center_cursor {Autoscroll::center()@@ -3812,8 +3827,6 @@ impl Editor {selection.collapse_to(cursor, goal);});});-- Some(())}pub fn select_down(&mut self, _: &SelectDown, cx: &mut ViewContext<Self>) {diff --git a/crates/editor/src/items.rs b/crates/editor/src/items.rsindex 73008ca7208..0efce57d5f2 100644--- a/crates/editor/src/items.rs+++ b/crates/editor/src/items.rs@@ -300,7 +300,7 @@ impl Item for Editor {false} else {let nav_history = self.nav_history.take();- self.set_scroll_anchor(data.scroll_anchor, cx);+ self.set_scroll_anchor(scroll_anchor, cx);self.change_selections(Some(Autoscroll::fit()), cx, |s| {s.select_ranges([offset..offset])});diff --git a/crates/vim/src/normal/change.rs b/crates/vim/src/normal/change.rsindex a32888f59e1..ca372801c7a 100644--- a/crates/vim/src/normal/change.rs+++ b/crates/vim/src/normal/change.rs@@ -200,7 +200,6 @@ mod test {Test testˇtest"}).await;- println!("Marker");cx.assert(indoc! {"Test testˇdiff --git a/crates/vim/src/test/vim_test_context.rs b/crates/vim/src/test/vim_test_context.rsindex e0d972896f2..723dac0581e 100644--- a/crates/vim/src/test/vim_test_context.rs+++ b/crates/vim/src/test/vim_test_context.rs@@ -51,8 +51,9 @@ impl<'a> VimTestContext<'a> {)});- // Setup search toolbars+ // Setup search toolbars and keypress hookworkspace.update(cx, |workspace, cx| {+ observe_keypresses(window_id, cx);workspace.active_pane().update(cx, |pane, cx| {pane.toolbar().update(cx, |toolbar, cx| {let buffer_search_bar = cx.add_view(BufferSearchBar::new);diff --git a/crates/vim/src/vim.rs b/crates/vim/src/vim.rsindex 4121d6f4bbe..898886714e5 100644--- a/crates/vim/src/vim.rs+++ b/crates/vim/src/vim.rs@@ -81,20 +81,20 @@ pub fn init(cx: &mut MutableAppContext) {.detach();}-// Any keystrokes not mapped to vim should clar the active operator+// Any keystrokes not mapped to vim should clear the active operatorpub fn observe_keypresses(window_id: usize, cx: &mut MutableAppContext) {cx.observe_keystrokes(window_id, |_keystroke, _result, handled_by, cx| {dbg!(_keystroke);- dbg!(_result);if let Some(handled_by) = handled_by {- dbg!(handled_by.name());if handled_by.namespace() == "vim" {+ println!("Vim action. Don't clear");return true;}}Vim::update(cx, |vim, cx| {if vim.active_operator().is_some() {+ println!("Clearing operator");vim.clear_operator(cx);}});