summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcossonleo2021-10-27 09:42:11 +0000
committerBlaž Hrastnik2021-10-29 01:04:12 +0000
commitf1d339919f4299d570bb6f7fcf5fcc58c0f281cf (patch)
treedd2b4868130783d8fc4a96a223cf1f2acf8d0678
parent45fadf61518b36c2e020f7262f136588dc96b03e (diff)
add expand_selection to last_motion
-rw-r--r--helix-term/src/commands.rs16
1 files changed, 10 insertions, 6 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index b3be6d5b..08750aeb 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -4348,13 +4348,17 @@ fn rotate_selection_contents_backward(cx: &mut Context) {
// tree sitter node selection
fn expand_selection(cx: &mut Context) {
- let (view, doc) = current!(cx.editor);
+ let motion = |editor: &mut Editor| {
+ let (view, doc) = current!(editor);
- if let Some(syntax) = doc.syntax() {
- let text = doc.text().slice(..);
- let selection = object::expand_selection(syntax, text, doc.selection(view.id));
- doc.set_selection(view.id, selection);
- }
+ if let Some(syntax) = doc.syntax() {
+ let text = doc.text().slice(..);
+ let selection = object::expand_selection(syntax, text, doc.selection(view.id));
+ doc.set_selection(view.id, selection);
+ }
+ };
+ motion(&mut cx.editor);
+ cx.editor.last_motion = Some(Motion(Box::new(motion)));
}
fn match_brackets(cx: &mut Context) {