From f1d339919f4299d570bb6f7fcf5fcc58c0f281cf Mon Sep 17 00:00:00 2001 From: cossonleo Date: Wed, 27 Oct 2021 17:42:11 +0800 Subject: add expand_selection to last_motion --- helix-term/src/commands.rs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'helix-term') 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) { -- cgit v1.2.3-70-g09d2