fix final failing tests

This commit is contained in:
Kay Simmons 2022-12-08 14:39:48 -08:00
parent f6f41510d2
commit 2cf48c03f9
6 changed files with 55 additions and 48 deletions

View file

@ -8,6 +8,22 @@
"Namespace": "G" "Namespace": "G"
} }
], ],
"i": [
"vim::PushOperator",
{
"Object": {
"around": false
}
}
],
"a": [
"vim::PushOperator",
{
"Object": {
"around": true
}
}
],
"h": "vim::Left", "h": "vim::Left",
"backspace": "vim::Backspace", "backspace": "vim::Backspace",
"j": "vim::Down", "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", "context": "Editor && vim_mode == normal && vim_operator == none",
"bindings": { "bindings": {

View file

@ -3709,18 +3709,30 @@ impl Editor {
}) })
} }
pub fn move_page_up(&mut self, action: &MovePageUp, cx: &mut ViewContext<Self>) -> Option<()> { pub fn move_page_up(&mut self, action: &MovePageUp, cx: &mut ViewContext<Self>) {
self.take_rename(true, cx)?; if self.take_rename(true, cx).is_some() {
if self.context_menu.as_mut()?.select_first(cx) { return;
return None; }
if self
.context_menu
.as_mut()
.map(|menu| menu.select_first(cx))
.unwrap_or(false)
{
return;
} }
if matches!(self.mode, EditorMode::SingleLine) { if matches!(self.mode, EditorMode::SingleLine) {
cx.propagate_action(); 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 { let autoscroll = if action.center_cursor {
Autoscroll::center() Autoscroll::center()
@ -3739,8 +3751,6 @@ impl Editor {
selection.collapse_to(cursor, goal); selection.collapse_to(cursor, goal);
}); });
}); });
Some(())
} }
pub fn select_up(&mut self, _: &SelectUp, cx: &mut ViewContext<Self>) { pub fn select_up(&mut self, _: &SelectUp, cx: &mut ViewContext<Self>) {
@ -3775,25 +3785,30 @@ impl Editor {
}); });
} }
pub fn move_page_down( pub fn move_page_down(&mut self, action: &MovePageDown, cx: &mut ViewContext<Self>) {
&mut self,
action: &MovePageDown,
cx: &mut ViewContext<Self>,
) -> Option<()> {
if self.take_rename(true, cx).is_some() { if self.take_rename(true, cx).is_some() {
return None; return;
} }
if self.context_menu.as_mut()?.select_last(cx) { if self
return None; .context_menu
.as_mut()
.map(|menu| menu.select_last(cx))
.unwrap_or(false)
{
return;
} }
if matches!(self.mode, EditorMode::SingleLine) { if matches!(self.mode, EditorMode::SingleLine) {
cx.propagate_action(); 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 { let autoscroll = if action.center_cursor {
Autoscroll::center() Autoscroll::center()
@ -3812,8 +3827,6 @@ impl Editor {
selection.collapse_to(cursor, goal); selection.collapse_to(cursor, goal);
}); });
}); });
Some(())
} }
pub fn select_down(&mut self, _: &SelectDown, cx: &mut ViewContext<Self>) { pub fn select_down(&mut self, _: &SelectDown, cx: &mut ViewContext<Self>) {

View file

@ -300,7 +300,7 @@ impl Item for Editor {
false false
} else { } else {
let nav_history = self.nav_history.take(); 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| { self.change_selections(Some(Autoscroll::fit()), cx, |s| {
s.select_ranges([offset..offset]) s.select_ranges([offset..offset])
}); });

View file

@ -200,7 +200,6 @@ mod test {
Test test Test test
ˇtest"}) ˇtest"})
.await; .await;
println!("Marker");
cx.assert(indoc! {" cx.assert(indoc! {"
Test test Test test
ˇ ˇ

View file

@ -51,8 +51,9 @@ impl<'a> VimTestContext<'a> {
) )
}); });
// Setup search toolbars // Setup search toolbars and keypress hook
workspace.update(cx, |workspace, cx| { workspace.update(cx, |workspace, cx| {
observe_keypresses(window_id, cx);
workspace.active_pane().update(cx, |pane, cx| { workspace.active_pane().update(cx, |pane, cx| {
pane.toolbar().update(cx, |toolbar, cx| { pane.toolbar().update(cx, |toolbar, cx| {
let buffer_search_bar = cx.add_view(BufferSearchBar::new); let buffer_search_bar = cx.add_view(BufferSearchBar::new);

View file

@ -81,20 +81,20 @@ pub fn init(cx: &mut MutableAppContext) {
.detach(); .detach();
} }
// Any keystrokes not mapped to vim should clar the active operator // Any keystrokes not mapped to vim should clear the active operator
pub fn observe_keypresses(window_id: usize, cx: &mut MutableAppContext) { pub fn observe_keypresses(window_id: usize, cx: &mut MutableAppContext) {
cx.observe_keystrokes(window_id, |_keystroke, _result, handled_by, cx| { cx.observe_keystrokes(window_id, |_keystroke, _result, handled_by, cx| {
dbg!(_keystroke); dbg!(_keystroke);
dbg!(_result);
if let Some(handled_by) = handled_by { if let Some(handled_by) = handled_by {
dbg!(handled_by.name());
if handled_by.namespace() == "vim" { if handled_by.namespace() == "vim" {
println!("Vim action. Don't clear");
return true; return true;
} }
} }
Vim::update(cx, |vim, cx| { Vim::update(cx, |vim, cx| {
if vim.active_operator().is_some() { if vim.active_operator().is_some() {
println!("Clearing operator");
vim.clear_operator(cx); vim.clear_operator(cx);
} }
}); });