aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src
diff options
context:
space:
mode:
authorNathan Vegdahl2021-07-19 04:59:31 +0000
committerNathan Vegdahl2021-07-19 04:59:31 +0000
commit6c038bb0151c6aeb43fc94bd2dc3d516a71d346c (patch)
treee752a3d31d166a11f5cedc7d138edff43416aa5a /helix-term/src
parentc2fd55e1685d22de2facf5acbfe6b7ddc02c7c84 (diff)
Update word selection/navigation to work with gap indexing.
Also tweaked some of the existing behavior that seemed inconsistent and/or buggy. It's mostly identical, just a few corner cases are different.
Diffstat (limited to 'helix-term/src')
-rw-r--r--helix-term/src/commands.rs75
1 files changed, 48 insertions, 27 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index 41b342b2..1f84db6b 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -498,6 +498,7 @@ fn move_next_word_start(cx: &mut Context) {
view.id,
doc.selection(view.id)
.clone()
+ .min_width_1(doc.text().slice(..))
.transform(|range| movement::move_next_word_start(doc.text().slice(..), range, count)),
);
}
@@ -509,6 +510,7 @@ fn move_prev_word_start(cx: &mut Context) {
view.id,
doc.selection(view.id)
.clone()
+ .min_width_1(doc.text().slice(..))
.transform(|range| movement::move_prev_word_start(doc.text().slice(..), range, count)),
);
}
@@ -520,6 +522,7 @@ fn move_next_word_end(cx: &mut Context) {
view.id,
doc.selection(view.id)
.clone()
+ .min_width_1(doc.text().slice(..))
.transform(|range| movement::move_next_word_end(doc.text().slice(..), range, count)),
);
}
@@ -529,9 +532,12 @@ fn move_next_long_word_start(cx: &mut Context) {
let (view, doc) = current!(cx.editor);
doc.set_selection(
view.id,
- doc.selection(view.id).clone().transform(|range| {
- movement::move_next_long_word_start(doc.text().slice(..), range, count)
- }),
+ doc.selection(view.id)
+ .clone()
+ .min_width_1(doc.text().slice(..))
+ .transform(|range| {
+ movement::move_next_long_word_start(doc.text().slice(..), range, count)
+ }),
);
}
@@ -540,9 +546,12 @@ fn move_prev_long_word_start(cx: &mut Context) {
let (view, doc) = current!(cx.editor);
doc.set_selection(
view.id,
- doc.selection(view.id).clone().transform(|range| {
- movement::move_prev_long_word_start(doc.text().slice(..), range, count)
- }),
+ doc.selection(view.id)
+ .clone()
+ .min_width_1(doc.text().slice(..))
+ .transform(|range| {
+ movement::move_prev_long_word_start(doc.text().slice(..), range, count)
+ }),
);
}
@@ -551,9 +560,12 @@ fn move_next_long_word_end(cx: &mut Context) {
let (view, doc) = current!(cx.editor);
doc.set_selection(
view.id,
- doc.selection(view.id).clone().transform(|range| {
- movement::move_next_long_word_end(doc.text().slice(..), range, count)
- }),
+ doc.selection(view.id)
+ .clone()
+ .min_width_1(doc.text().slice(..))
+ .transform(|range| {
+ movement::move_next_long_word_end(doc.text().slice(..), range, count)
+ }),
);
}
@@ -574,12 +586,15 @@ fn extend_next_word_start(cx: &mut Context) {
let (view, doc) = current!(cx.editor);
doc.set_selection(
view.id,
- doc.selection(view.id).clone().transform(|range| {
- let text = doc.text().slice(..);
- let word = movement::move_next_word_start(text, range, count);
- let pos = word.head;
- range.put(text, pos, true)
- }),
+ doc.selection(view.id)
+ .clone()
+ .min_width_1(doc.text().slice(..))
+ .transform(|range| {
+ let text = doc.text().slice(..);
+ let word = movement::move_next_word_start(text, range, count);
+ let pos = word.head;
+ range.put(text, pos, true)
+ }),
);
}
@@ -588,12 +603,15 @@ fn extend_prev_word_start(cx: &mut Context) {
let (view, doc) = current!(cx.editor);
doc.set_selection(
view.id,
- doc.selection(view.id).clone().transform(|range| {
- let text = doc.text().slice(..);
- let word = movement::move_prev_word_start(text, range, count);
- let pos = word.head;
- range.put(text, pos, true)
- }),
+ doc.selection(view.id)
+ .clone()
+ .min_width_1(doc.text().slice(..))
+ .transform(|range| {
+ let text = doc.text().slice(..);
+ let word = movement::move_prev_word_start(text, range, count);
+ let pos = word.head;
+ range.put(text, pos, true)
+ }),
);
}
@@ -602,12 +620,15 @@ fn extend_next_word_end(cx: &mut Context) {
let (view, doc) = current!(cx.editor);
doc.set_selection(
view.id,
- doc.selection(view.id).clone().transform(|range| {
- let text = doc.text().slice(..);
- let word = movement::move_next_word_end(text, range, count);
- let pos = word.head;
- range.put(text, pos, true)
- }),
+ doc.selection(view.id)
+ .clone()
+ .min_width_1(doc.text().slice(..))
+ .transform(|range| {
+ let text = doc.text().slice(..);
+ let word = movement::move_next_word_end(text, range, count);
+ let pos = word.head;
+ range.put(text, pos, true)
+ }),
);
}