Skip to content

Commit

Permalink
Extend textobject selections in select mode
Browse files Browse the repository at this point in the history
  • Loading branch information
the-mikedavis committed Sep 22, 2022
1 parent 99bde07 commit 98d4e4f
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions helix-term/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4257,16 +4257,27 @@ fn goto_ts_object_impl(cx: &mut Context, object: &'static str, direction: Direct
let root = syntax.tree().root_node();

let selection = doc.selection(view.id).clone().transform(|range| {
movement::goto_treesitter_object(
let new_range = movement::goto_treesitter_object(
text,
range,
object,
direction,
root,
lang_config,
count,
)
.with_direction(direction)
);

if editor.mode == Mode::Select {
let head = if new_range.head < range.anchor {
new_range.anchor
} else {
new_range.head
};

Range::new(range.anchor, head)
} else {
new_range.with_direction(direction)
}
});

doc.set_selection(view.id, selection);
Expand Down

0 comments on commit 98d4e4f

Please sign in to comment.