From 19d2e74c0e4b83a284f756a7fd51aba7cf72ab4b Mon Sep 17 00:00:00 2001 From: Waleed Dahshan Date: Tue, 30 Jan 2024 04:02:15 +1100 Subject: [PATCH] add condition to cursor moving back on normal --- helix-view/src/editor.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index eca488e740026..3ee47088e8c50 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -1904,9 +1904,14 @@ impl Editor { if doc.restore_cursor { let text = doc.text().slice(..); let selection = doc.selection(view.id).clone().transform(|range| { + let mut head = range.to(); + if range.head > range.anchor { + head = graphemes::prev_grapheme_boundary(text, head); + } + Range::new( range.from(), - graphemes::prev_grapheme_boundary(text, range.to()), + head ) });