summaryrefslogtreecommitdiff
path: root/helix-term/src/commands.rs
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-04-05 07:35:04 +0000
committerBlaž Hrastnik2021-04-05 07:35:04 +0000
commit59a0fc7b59186b3bedb01dd5b958d3b97b9fbba2 (patch)
tree820018ef4c0719be2daef34cab3ccc5febd67850 /helix-term/src/commands.rs
parent16350399ac4eb15274e065f113ad808c96dc600f (diff)
w, b, e: Match kakoune's behavior in selecting by default.
I initially preferred only moving the cursor, but selecting the whole word is a lot nicer for things like wd (instead of vwd).
Diffstat (limited to 'helix-term/src/commands.rs')
-rw-r--r--helix-term/src/commands.rs22
1 files changed, 11 insertions, 11 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index 1db23537..97078794 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -218,8 +218,7 @@ pub fn move_next_word_start(cx: &mut Context) {
let text = doc.text().slice(..);
let selection = doc.selection(view.id).transform(|range| {
- let pos = movement::move_next_word_start(text, range.head, count);
- Range::new(pos, pos)
+ movement::move_next_word_start(text, range.head, count).unwrap_or(range)
});
doc.set_selection(view.id, selection);
@@ -231,8 +230,7 @@ pub fn move_prev_word_start(cx: &mut Context) {
let text = doc.text().slice(..);
let selection = doc.selection(view.id).transform(|range| {
- let pos = movement::move_prev_word_start(text, range.head, count);
- Range::new(pos, pos)
+ movement::move_prev_word_start(text, range.head, count).unwrap_or(range)
});
doc.set_selection(view.id, selection);
@@ -243,10 +241,9 @@ pub fn move_next_word_end(cx: &mut Context) {
let (view, doc) = cx.current();
let text = doc.text().slice(..);
- let selection = doc.selection(view.id).transform(|range| {
- let pos = movement::move_next_word_end(text, range.head, count);
- Range::new(pos, pos)
- });
+ let selection = doc
+ .selection(view.id)
+ .transform(|range| movement::move_next_word_end(text, range.head, count).unwrap_or(range));
doc.set_selection(view.id, selection);
}
@@ -271,7 +268,8 @@ pub fn extend_next_word_start(cx: &mut Context) {
let text = doc.text().slice(..);
let selection = doc.selection(view.id).transform(|mut range| {
- let pos = movement::move_next_word_start(text, range.head, count);
+ let word = movement::move_next_word_start(text, range.head, count).unwrap_or(range);
+ let pos = word.head;
Range::new(range.anchor, pos)
});
@@ -284,7 +282,8 @@ pub fn extend_prev_word_start(cx: &mut Context) {
let text = doc.text().slice(..);
let selection = doc.selection(view.id).transform(|mut range| {
- let pos = movement::move_prev_word_start(text, range.head, count);
+ let word = movement::move_prev_word_start(text, range.head, count).unwrap_or(range);
+ let pos = word.head;
Range::new(range.anchor, pos)
});
doc.set_selection(view.id, selection);
@@ -296,7 +295,8 @@ pub fn extend_next_word_end(cx: &mut Context) {
let text = doc.text().slice(..);
let selection = doc.selection(view.id).transform(|mut range| {
- let pos = movement::move_next_word_end(text, range.head, count);
+ let word = movement::move_next_word_end(text, range.head, count).unwrap_or(range);
+ let pos = word.head;
Range::new(range.anchor, pos)
});