fix: game crashes on pasting text

This commit is contained in:
minjaesong
2024-02-17 15:26:18 +09:00
parent a7ba39a43c
commit 6da155d4f3
4 changed files with 9 additions and 7 deletions

View File

@@ -504,7 +504,7 @@ class UIItemTextLineInput(
textbuf.addAll(actuallyInserted)
cursorX += codepoints.size
currentTextLenPx = App.fontGame.getWidth(CodepointSequence(textbuf.subList(0, cursorX)))
currentTextLenPx = App.fontGame.getWidth(CodepointSequence(textbuf.subList(0, minOf(cursorX, textbuf.size))))
moveCursorForward(currentTextLenPx - oldTextLenPx)
oldTextLenPx = currentTextLenPx