aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src
diff options
context:
space:
mode:
Diffstat (limited to 'helix-term/src')
-rw-r--r--helix-term/src/commands.rs20
1 files changed, 19 insertions, 1 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index e76962f0..5ab0926a 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -2193,7 +2193,25 @@ fn goto_mode(cx: &mut Context) {
}
fn select_mode(cx: &mut Context) {
- doc_mut!(cx.editor).mode = Mode::Select;
+ let (view, doc) = current!(cx.editor);
+
+ // Make sure all selections are at least 1-wide.
+ // (With the exception of being in an empty document, of course.)
+ doc.set_selection(
+ view.id,
+ doc.selection(view.id).clone().transform(|range| {
+ if range.is_empty() && range.head == doc.text().len_chars() {
+ Range::new(
+ graphemes::prev_grapheme_boundary(doc.text().slice(..), range.anchor),
+ range.head,
+ )
+ } else {
+ range.min_width_1(doc.text().slice(..))
+ }
+ }),
+ );
+
+ doc.mode = Mode::Select;
}
fn exit_select_mode(cx: &mut Context) {