Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'helix-term/src/commands.rs')
-rw-r--r--helix-term/src/commands.rs21
1 files changed, 19 insertions, 2 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index 99e7608f..7618fd0a 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -438,8 +438,9 @@ impl MappableCommand {
reverse_selection_contents, "Reverse selections contents",
expand_selection, "Expand selection to parent syntax node",
shrink_selection, "Shrink selection to previously expanded syntax node",
- select_next_sibling, "Select next sibling in syntax tree",
- select_prev_sibling, "Select previous sibling in syntax tree",
+ select_next_sibling, "Select next sibling in the syntax tree",
+ select_prev_sibling, "Select previous sibling the in syntax tree",
+ select_all_siblings, "Select all siblings in the syntax tree",
jump_forward, "Jump forward on jumplist",
jump_backward, "Jump backward on jumplist",
save_selection, "Save current selection to jumplist",
@@ -4974,6 +4975,22 @@ pub fn extend_parent_node_start(cx: &mut Context) {
move_node_bound_impl(cx, Direction::Backward, Movement::Extend)
}
+fn select_all_siblings(cx: &mut Context) {
+ let motion = |editor: &mut Editor| {
+ let (view, doc) = current!(editor);
+
+ if let Some(syntax) = doc.syntax() {
+ let text = doc.text().slice(..);
+ let current_selection = doc.selection(view.id);
+ let selection =
+ object::select_all_siblings(syntax.tree(), text, current_selection.clone());
+ doc.set_selection(view.id, selection);
+ }
+ };
+
+ cx.editor.apply_motion(motion);
+}
+
fn match_brackets(cx: &mut Context) {
let (view, doc) = current!(cx.editor);
let is_select = cx.editor.mode == Mode::Select;