aboutsummaryrefslogtreecommitdiff
path: root/helix-view
diff options
context:
space:
mode:
authorWaleed Dahshan2024-01-29 21:58:33 +0000
committerGitHub2024-01-29 21:58:33 +0000
commitcf4492174d0ee27bd3c73a5fa57fe3a26aa064be (patch)
tree83dd4520404738808e0185f33feb23bf2c7a830c /helix-view
parent87a720c3a13ccc7245f5b0befc008db5bd039032 (diff)
Use range positions to determine insert_newline motion (#9448)
* use anchor and head positions to determine motion * use range cursor to decide extending or shifting * add condition to cursor moving back on normal
Diffstat (limited to 'helix-view')
-rw-r--r--helix-view/src/editor.rs10
1 files changed, 6 insertions, 4 deletions
diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs
index db0d4030..0fa6d67c 100644
--- a/helix-view/src/editor.rs
+++ b/helix-view/src/editor.rs
@@ -1990,10 +1990,12 @@ impl Editor {
if doc.restore_cursor {
let text = doc.text().slice(..);
let selection = doc.selection(view.id).clone().transform(|range| {
- Range::new(
- range.from(),
- graphemes::prev_grapheme_boundary(text, range.to()),
- )
+ let mut head = range.to();
+ if range.head > range.anchor {
+ head = graphemes::prev_grapheme_boundary(text, head);
+ }
+
+ Range::new(range.from(), head)
});
doc.set_selection(view.id, selection);