Fix #20628: Stop caret left moving off the input string

This commit is contained in:
Ota authored and GitHub committed 2024-01-19 13:48:51 +01:00
1 parent 00b5932557
commit 33523c98c2
2 files changed
+6 -3

No files matched your search

+1
View File
@@ -4,6 +4,7 @@
- Improved: [#20951] Activate OpenRCT2 window after using native file dialog on macOS.
- Fix: [#20255] Images from the last hovered-over coaster in the object selection are not freed.
- Fix: [#20616] Confirmation button in the track designer’s quit prompt has the wrong text.
- Fix: [#20628] Moving caret using Ctrl+left can move too far when using a multibyte grapheme.
- Fix: [#21145] [Plugin] setInterval/setTimeout handle conflict.
- Fix: [#21157] [Plugin] Widgets do not redraw correctly when updating disabled or visibility state.
- Fix: [#21158] [Plugin] Potential crash using setInterval/setTimeout within the callback.
+5 -3
View File
@@ -276,7 +276,8 @@ void TextComposition::CaretMoveToLeftToken()
lastChar = selectionOffset;
break;
}
if (selectionOffset == 0)
break;
ch--;
selectionOffset--;
}
@@ -295,12 +296,13 @@ void TextComposition::CaretMoveToLeftToken()
break;
lastChar = selectionOffset;
if (selectionOffset == 0)
break;
ch--;
selectionOffset--;
}
_session.SelectionSize = std::max<size_t>(0, _session.SelectionSize - (selectionOffset - _session.SelectionStart));
_session.SelectionSize = _session.SelectionSize - (selectionOffset - _session.SelectionStart);
_session.SelectionStart = selectionOffset == 0 ? 0 : lastChar;
}