Make TextInputPanel obey acceptsCharacter when pasting from clipboard

This commit is contained in:
DBotThePony 2023-07-15 19:40:11 +07:00
parent 9fe8d1734e
commit 9394de61d9
Signed by: DBot
GPG Key ID: DCC23B5715498507

View File

@ -894,7 +894,7 @@ open class TextInputPanel<out S : Screen>(
pushbackSnapshot()
if (multiLine) {
val insert = minecraft.keyboardHandler.clipboard.replace("\t", " ").split(NEWLINES).toMutableList()
val insert = minecraft.keyboardHandler.clipboard.replace("\t", " ").filter { acceptsCharacter(it) }.split(NEWLINES).toMutableList()
val actualLastSize = insert.lastOrNull()?.length ?: 0
val line = this[cursorLine]
@ -933,7 +933,7 @@ open class TextInputPanel<out S : Screen>(
cursorRow = actualLastSize
}
} else {
val insert = minecraft.keyboardHandler.clipboard.replace("\t", " ").replace(NEWLINES, "")
val insert = minecraft.keyboardHandler.clipboard.replace("\t", " ").replace(NEWLINES, "").filter { acceptsCharacter(it) }
val line = this[cursorLine]
if (line == null) {