Skip to content

Commit

Permalink
add condition to cursor moving back on normal
Browse files Browse the repository at this point in the history
  • Loading branch information
wmstack committed Jan 29, 2024
1 parent 8703ad4 commit 0f15c71
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion helix-view/src/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1904,9 +1904,15 @@ impl Editor {
if doc.restore_cursor {
let text = doc.text().slice(..);
let selection = doc.selection(view.id).clone().transform(|range| {
// only move back when
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
)
});

Expand Down

0 comments on commit 0f15c71

Please sign in to comment.