Fix crash related to null text
parent
07aac12a2b
commit
9ef13e5f67
|
@ -48,26 +48,28 @@ export default abstract class MessageUiHandler extends AwaitableUiHandler {
|
||||||
text = text.slice(0, actionMatch.index) + text.slice(actionMatch.index + actionMatch[2].length + 4);
|
text = text.slice(0, actionMatch.index) + text.slice(actionMatch.index + actionMatch[2].length + 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Predetermine overflow line breaks to avoid words breaking while displaying
|
if (text) {
|
||||||
const textWords = text.split(' ');
|
// Predetermine overflow line breaks to avoid words breaking while displaying
|
||||||
let lastLineCount = 1;
|
const textWords = text.split(' ');
|
||||||
let newText = textWords[0];
|
let lastLineCount = 1;
|
||||||
for (let w = 1; w < textWords.length; w++) {
|
let newText = textWords[0];
|
||||||
const nextWordText = `${newText} ${textWords[w]}`;
|
for (let w = 1; w < textWords.length; w++) {
|
||||||
if (textWords[w].includes('\n')) {
|
const nextWordText = `${newText} ${textWords[w]}`;
|
||||||
newText = nextWordText;
|
if (textWords[w].includes('\n')) {
|
||||||
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;
|
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) {
|
if (this.textTimer) {
|
||||||
this.textTimer.remove();
|
this.textTimer.remove();
|
||||||
|
|
Loading…
Reference in New Issue