diff options
author | Ivan Tham | 2022-04-05 00:43:04 +0000 |
---|---|---|
committer | GitHub | 2022-04-05 00:43:04 +0000 |
commit | e7beb32fd7b9262e61dad96fdf4b36ebdc5367f7 (patch) | |
tree | 3df0e7a20a0883905ad1c0fc100d823dfc13f174 /helix-term/src | |
parent | d3c8286ea0c984f69bbab09a480530a827647192 (diff) |
Add paragraph to last motion (#1956)
Fix #1954
Diffstat (limited to 'helix-term/src')
-rw-r--r-- | helix-term/src/commands.rs | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index b93cfc41..9a222427 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -905,22 +905,26 @@ fn move_next_long_word_end(cx: &mut Context) { fn move_para_impl<F>(cx: &mut Context, move_fn: F) where - F: Fn(RopeSlice, Range, usize, Movement) -> Range, + F: Fn(RopeSlice, Range, usize, Movement) -> Range + 'static, { let count = cx.count(); - let (view, doc) = current!(cx.editor); - let text = doc.text().slice(..); - let behavior = if doc.mode == Mode::Select { - Movement::Extend - } else { - Movement::Move - }; + let motion = move |editor: &mut Editor| { + let (view, doc) = current!(editor); + let text = doc.text().slice(..); + let behavior = if doc.mode == Mode::Select { + Movement::Extend + } else { + Movement::Move + }; - let selection = doc - .selection(view.id) - .clone() - .transform(|range| move_fn(text, range, count, behavior)); - doc.set_selection(view.id, selection); + let selection = doc + .selection(view.id) + .clone() + .transform(|range| move_fn(text, range, count, behavior)); + doc.set_selection(view.id, selection); + }; + motion(cx.editor); + cx.editor.last_motion = Some(Motion(Box::new(motion))); } fn move_prev_paragraph(cx: &mut Context) { |