This commit is contained in:
2026-02-07 23:00:30 +08:00
parent 44230e86c2
commit d222787db3

View File

@@ -253,6 +253,7 @@ function parseColorTokens(message: string, renderColor: boolean): ColorToken[] {
let inColorStart = false;
let inColorEnd = false;
let chars: string[] = [];
let startedColors: string[] = [];
const messageLength = message.length;
for (let i = 0; i < messageLength; i++) {
const c = message.charAt(i);
@@ -294,7 +295,21 @@ function parseColorTokens(message: string, renderColor: boolean): ColorToken[] {
colorStart: inColorStart,
color: chars.join(""),
});
if (inColorStart) {
startedColors.push(chars.join(""));
} else {
startedColors.pop();
}
chars = [];
} else if (chars.length === 0 && inColorEnd) {
const poppedColor = startedColors.pop();
if (poppedColor) {
tokens.push({
type: "color",
colorStart: false,
color: poppedColor,
});
}
}
inColorStart = false;
inColorEnd = false;