vim: Respect count for paragraphs (#33489)
Closes #32462 Release Notes: - vim: Paragraph objects now support counts (`d2ap`, `v2ap`, etc.) --------- Co-authored-by: Rift <no@e.mail> Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
This commit is contained in:
parent
ba4fc1bcfc
commit
97c5c5a6e7
17 changed files with 182 additions and 54 deletions
|
@ -364,7 +364,13 @@ impl Vim {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn visual_object(&mut self, object: Object, window: &mut Window, cx: &mut Context<Vim>) {
|
||||
pub fn visual_object(
|
||||
&mut self,
|
||||
object: Object,
|
||||
count: Option<usize>,
|
||||
window: &mut Window,
|
||||
cx: &mut Context<Vim>,
|
||||
) {
|
||||
if let Some(Operator::Object { around }) = self.active_operator() {
|
||||
self.pop_operator(window, cx);
|
||||
let current_mode = self.mode;
|
||||
|
@ -390,7 +396,7 @@ impl Vim {
|
|||
);
|
||||
}
|
||||
|
||||
if let Some(range) = object.range(map, mut_selection, around) {
|
||||
if let Some(range) = object.range(map, mut_selection, around, count) {
|
||||
if !range.is_empty() {
|
||||
let expand_both_ways = object.always_expands_both_ways()
|
||||
|| selection.is_empty()
|
||||
|
@ -402,7 +408,7 @@ impl Vim {
|
|||
&& object.always_expands_both_ways()
|
||||
{
|
||||
if let Some(range) =
|
||||
object.range(map, selection.clone(), around)
|
||||
object.range(map, selection.clone(), around, count)
|
||||
{
|
||||
selection.start = range.start;
|
||||
selection.end = range.end;
|
||||
|
@ -1761,4 +1767,26 @@ mod test {
|
|||
});
|
||||
cx.shared_clipboard().await.assert_eq("quick\n");
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_v2ap(cx: &mut gpui::TestAppContext) {
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||
|
||||
cx.set_shared_state(indoc! {
|
||||
"The
|
||||
quicˇk
|
||||
|
||||
brown
|
||||
fox"
|
||||
})
|
||||
.await;
|
||||
cx.simulate_shared_keystrokes("v 2 a p").await;
|
||||
cx.shared_state().await.assert_eq(indoc! {
|
||||
"«The
|
||||
quick
|
||||
|
||||
brown
|
||||
fˇ»ox"
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue