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 authored and archseer committed Oct 3, 2022
1 parent 032d76c commit c253139
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 @@ -4282,16 +4282,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 c253139

Please sign in to comment.