Skip to content

Commit c253139

Browse files
the-mikedavisarchseer
authored andcommitted
Extend textobject selections in select mode
1 parent 032d76c commit c253139

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

helix-term/src/commands.rs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4282,16 +4282,27 @@ fn goto_ts_object_impl(cx: &mut Context, object: &'static str, direction: Direct
42824282
let root = syntax.tree().root_node();
42834283

42844284
let selection = doc.selection(view.id).clone().transform(|range| {
4285-
movement::goto_treesitter_object(
4285+
let new_range = movement::goto_treesitter_object(
42864286
text,
42874287
range,
42884288
object,
42894289
direction,
42904290
root,
42914291
lang_config,
42924292
count,
4293-
)
4294-
.with_direction(direction)
4293+
);
4294+
4295+
if editor.mode == Mode::Select {
4296+
let head = if new_range.head < range.anchor {
4297+
new_range.anchor
4298+
} else {
4299+
new_range.head
4300+
};
4301+
4302+
Range::new(range.anchor, head)
4303+
} else {
4304+
new_range.with_direction(direction)
4305+
}
42954306
});
42964307

42974308
doc.set_selection(view.id, selection);

0 commit comments

Comments
 (0)