From 1ae5a8bd666bf6a57b39c4eecd39c2f081b14ac4 Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Thu, 25 Jan 2024 02:53:39 +0200 Subject: [PATCH] #1630 Fix display mode regex depth calc --- public/script.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/public/script.js b/public/script.js index f7f48ef7f..68e486c01 100644 --- a/public/script.js +++ b/public/script.js @@ -1605,7 +1605,8 @@ function messageFormatting(mes, ch_name, isSystem, isUser, messageId) { } const usableMessages = chat.map((x, index) => ({ message: x, index: index })).filter(x => !x.message.is_system); - const depth = messageId >= 0 && usableMessages.some(x => x.index === messageId) ? (usableMessages.length - messageId - 1) : undefined; + const indexOf = usableMessages.findIndex(x => x.index === Number(messageId)); + const depth = messageId >= 0 && indexOf !== -1 ? (usableMessages.length - indexOf - 1) : undefined; // Always override the character name mes = getRegexedString(mes, regexPlacement, {