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 40f0e0e
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions helix-view/src/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1904,10 +1904,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);
Expand Down

0 comments on commit 40f0e0e

Please sign in to comment.