aboutsummaryrefslogtreecommitdiff
path: root/helix-core/src
diff options
context:
space:
mode:
Diffstat (limited to 'helix-core/src')
-rw-r--r--helix-core/src/selection.rs11
1 files changed, 9 insertions, 2 deletions
diff --git a/helix-core/src/selection.rs b/helix-core/src/selection.rs
index 21a6c108..7d2526b0 100644
--- a/helix-core/src/selection.rs
+++ b/helix-core/src/selection.rs
@@ -267,8 +267,15 @@ impl Selection {
}
#[must_use]
- pub fn cursor(&self) -> usize {
- self.primary().head
+ pub fn cursor(&self, text: RopeSlice) -> usize {
+ let range = self.primary();
+
+ // For 1-width cursor semantics.
+ if range.anchor < range.head {
+ prev_grapheme_boundary(text, range.head)
+ } else {
+ range.head
+ }
}
/// Ensure selection containing only the primary selection.