Fix crash related to null text

pull/57/head
Flashfyre 2024-04-07 19:11:34 -04:00
parent 07aac12a2b
commit 9ef13e5f67
1 changed files with 19 additions and 17 deletions

View File

@ -48,27 +48,29 @@ export default abstract class MessageUiHandler extends AwaitableUiHandler {
text = text.slice(0, actionMatch.index) + text.slice(actionMatch.index + actionMatch[2].length + 4);
}
// Predetermine overflow line breaks to avoid words breaking while displaying
const textWords = text.split(' ');
let lastLineCount = 1;
let newText = textWords[0];
for (let w = 1; w < textWords.length; w++) {
const nextWordText = `${newText} ${textWords[w]}`;
if (textWords[w].includes('\n')) {
newText = nextWordText;
lastLineCount++;
} else {
const lineCount = this.message.runWordWrap(nextWordText).split(/\n/g).length;
if (lineCount > lastLineCount) {
lastLineCount = lineCount;
newText = `${newText}\n${textWords[w]}`;
} else
if (text) {
// Predetermine overflow line breaks to avoid words breaking while displaying
const textWords = text.split(' ');
let lastLineCount = 1;
let newText = textWords[0];
for (let w = 1; w < textWords.length; w++) {
const nextWordText = `${newText} ${textWords[w]}`;
if (textWords[w].includes('\n')) {
newText = nextWordText;
lastLineCount++;
} else {
const lineCount = this.message.runWordWrap(nextWordText).split(/\n/g).length;
if (lineCount > lastLineCount) {
lastLineCount = lineCount;
newText = `${newText}\n${textWords[w]}`;
} else
newText = nextWordText;
}
}
text = newText;
}
text = newText;
if (this.textTimer) {
this.textTimer.remove();
if (this.textCallbackTimer)