Skip to content

Commit

Permalink
TextEditor: when scrollToCaret() is called with a selection range, pr…
Browse files Browse the repository at this point in the history
…efer the lower end of that range
  • Loading branch information
joshtynjala committed Sep 20, 2024
1 parent cb7284c commit 6d60122
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/moonshine/editor/text/TextEditor.hx
Original file line number Diff line number Diff line change
Expand Up @@ -1426,6 +1426,13 @@ class TextEditor extends FeathersControl implements IFocusObject implements ISta
// but it's safer to check just in case
if (textLineRenderer != null) {
var adjustedIndex = caretCharIndex;
// if there's a selection, prefer the lower value
if (_selectionStartCharIndex != -1 && adjustedIndex > _selectionStartCharIndex) {
adjustedIndex = _selectionStartCharIndex;
}
if (_selectionEndCharIndex != -1 && adjustedIndex > _selectionEndCharIndex) {
adjustedIndex = _selectionEndCharIndex;
}
var end = false;
var line = lines.get(_caretLineIndex);
// get the bounds of the final real character so that the horizontal
Expand Down

0 comments on commit 6d60122

Please sign in to comment.