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

This commit is contained in:
Ota 2024-01-19 13:48:51 +01:00 committed by GitHub
parent 00b5932557
commit 33523c98c2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 3 deletions

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 designers 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.

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;
}