Skip to content

Commit

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

// only move back when therere is a selection.
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 fe29c3d

Please sign in to comment.