From 6cfb1acb9d1456e854a2c44ee8fc057f45b29ea9 Mon Sep 17 00:00:00 2001 From: Blaž Hrastnik Date: Mon, 22 Feb 2021 15:50:41 +0900 Subject: commands: Implement expand_selection. --- helix-term/src/commands.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'helix-term/src/commands.rs') diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index c048ff9a..c37c0710 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -1,6 +1,7 @@ use helix_core::{ comment, graphemes, indent::TAB_WIDTH, + object, regex::{self, Regex}, register, selection, state::{Direction, Granularity, State}, @@ -1023,3 +1024,15 @@ pub fn toggle_comments(cx: &mut Context) { doc.apply(&transaction); } + +// tree sitter node selection + +pub fn expand_selection(cx: &mut Context) { + let doc = cx.doc(); + + if let Some(syntax) = &doc.syntax { + let text = doc.text().slice(..); + let selection = object::expand_selection(syntax, text, doc.selection()); + doc.set_selection(selection); + } +} -- cgit v1.2.3-70-g09d2