aboutsummaryrefslogtreecommitdiff
path: root/helix-term
diff options
context:
space:
mode:
authorMichael Davis2022-07-30 16:57:39 +0000
committerBlaž Hrastnik2022-10-03 14:44:08 +0000
commitc253139790034bac62bb51da0efd133d12b7f2c6 (patch)
treeee70363ac05f7195929ccab5b224dc8445ab772c /helix-term
parent032d76ccf2ed4f46c51bf60d190c23edc6b26220 (diff)
Extend textobject selections in select mode
Diffstat (limited to 'helix-term')
-rw-r--r--helix-term/src/commands.rs17
1 files changed, 14 insertions, 3 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index b2378222..cb561d6d 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -4282,7 +4282,7 @@ 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,
@@ -4290,8 +4290,19 @@ fn goto_ts_object_impl(cx: &mut Context, object: &'static str, direction: Direct
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);