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:
Rift 2025-06-28 00:05:47 -04:00 committed by GitHub
parent ba4fc1bcfc
commit 97c5c5a6e7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 182 additions and 54 deletions

View file

@ -105,6 +105,7 @@ impl Vim {
&mut self,
object: Object,
around: bool,
times: Option<usize>,
window: &mut Window,
cx: &mut Context<Self>,
) {
@ -115,7 +116,7 @@ impl Vim {
editor.transact(window, cx, |editor, window, cx| {
editor.change_selections(Default::default(), window, cx, |s| {
s.move_with(|map, selection| {
objects_found |= object.expand_selection(map, selection, around);
objects_found |= object.expand_selection(map, selection, around, times);
});
});
if objects_found {

View file

@ -82,6 +82,7 @@ impl Vim {
object: Object,
around: bool,
mode: ConvertTarget,
times: Option<usize>,
window: &mut Window,
cx: &mut Context<Self>,
) {
@ -92,7 +93,7 @@ impl Vim {
let mut original_positions: HashMap<_, _> = Default::default();
editor.change_selections(SelectionEffects::no_scroll(), window, cx, |s| {
s.move_with(|map, selection| {
object.expand_selection(map, selection, around);
object.expand_selection(map, selection, around, times);
original_positions.insert(
selection.id,
map.display_point_to_anchor(selection.start, Bias::Left),

View file

@ -91,6 +91,7 @@ impl Vim {
&mut self,
object: Object,
around: bool,
times: Option<usize>,
window: &mut Window,
cx: &mut Context<Self>,
) {
@ -103,7 +104,7 @@ impl Vim {
let mut should_move_to_start: HashSet<_> = Default::default();
editor.change_selections(Default::default(), window, cx, |s| {
s.move_with(|map, selection| {
object.expand_selection(map, selection, around);
object.expand_selection(map, selection, around, times);
let offset_range = selection.map(|p| p.to_offset(map, Bias::Left)).range();
let mut move_selection_start_to_previous_line =
|map: &DisplaySnapshot, selection: &mut Selection<DisplayPoint>| {

View file

@ -240,7 +240,7 @@ impl Vim {
editor.set_clip_at_line_ends(false, cx);
editor.change_selections(SelectionEffects::no_scroll(), window, cx, |s| {
s.move_with(|map, selection| {
object.expand_selection(map, selection, around);
object.expand_selection(map, selection, around, None);
});
});

View file

@ -46,6 +46,7 @@ impl Vim {
&mut self,
object: Object,
around: bool,
times: Option<usize>,
window: &mut Window,
cx: &mut Context<Self>,
) {
@ -57,7 +58,7 @@ impl Vim {
s.move_with(|map, selection| {
let anchor = map.display_point_to_anchor(selection.head(), Bias::Right);
original_positions.insert(selection.id, anchor);
object.expand_selection(map, selection, around);
object.expand_selection(map, selection, around, times);
});
});
editor.toggle_comments(&Default::default(), window, cx);

View file

@ -66,6 +66,7 @@ impl Vim {
&mut self,
object: Object,
around: bool,
times: Option<usize>,
window: &mut Window,
cx: &mut Context<Self>,
) {
@ -75,7 +76,7 @@ impl Vim {
let mut start_positions: HashMap<_, _> = Default::default();
editor.change_selections(SelectionEffects::no_scroll(), window, cx, |s| {
s.move_with(|map, selection| {
object.expand_selection(map, selection, around);
object.expand_selection(map, selection, around, times);
let start_position = (selection.start, selection.goal);
start_positions.insert(selection.id, start_position);
});