aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/commands.rs
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-03-22 08:58:49 +0000
committerBlaž Hrastnik2021-03-22 08:58:49 +0000
commit73c92a0bc1499f02092a7425c45d4992f4e573a1 (patch)
tree1de38a0f16e3acd44998b1f8368df726a7962e0c /helix-term/src/commands.rs
parentbd607b4cbd58e2bff06e36f614ff61b7d1a721c3 (diff)
Implement m / match_brackets (using tree sitter).
Diffstat (limited to 'helix-term/src/commands.rs')
-rw-r--r--helix-term/src/commands.rs14
1 files changed, 13 insertions, 1 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index b9ee933d..3f0e32a0 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -1,5 +1,5 @@
use helix_core::{
- comment, coords_at_pos, graphemes,
+ comment, coords_at_pos, graphemes, match_brackets,
movement::{self, Direction},
object, pos_at_coords,
regex::{self, Regex},
@@ -1592,3 +1592,15 @@ pub fn expand_selection(cx: &mut Context) {
doc.set_selection(selection);
}
}
+
+pub fn match_brackets(cx: &mut Context) {
+ let mut doc = cx.doc();
+
+ if let Some(syntax) = doc.syntax() {
+ let pos = doc.selection().cursor();
+ if let Some(pos) = match_brackets::find(syntax, doc.text(), pos) {
+ let selection = Selection::point(pos);
+ doc.set_selection(selection);
+ };
+ }
+}