Merge pull request #3147 from SillyTavern/off-by-one Fix -0 comparison

a7c8b936520581e2d5fb869ee119fcfe49f6591d

Cohee <18619528+Cohee1207@users.noreply.github.com>

Signed
1 files changed, +8 -8Ignore whitespace
public/scripts/slash-commands.js+8 -8
@@ -269,7 +269,7 @@ export function initDefaultSlashCommands() {
269269 }),
270270 SlashCommandNamedArgument.fromProps({
271271 name: 'at',
272272 description: 'position to insert the message (index-based, corresponding to message id). If not set, the message will be inserted at the end of the chat.\nNegative values (including -0) are accepted and will work similarly to how \'depth\' usually works. For example, -1 will insert the message right before the last message in chat.',
273273 typeList: [ARGUMENT_TYPE.NUMBER],
274274 enumProvider: commonEnumProviders.messages({ allowIdAfter: true }),
275275 }),
@@ -325,7 +325,7 @@ export function initDefaultSlashCommands() {
325325 ),
326326 SlashCommandNamedArgument.fromProps({
327327 name: 'at',
328328 description: 'position to insert the message (index-based, corresponding to message id). If not set, the message will be inserted at the end of the chat.\nNegative values (including -0) are accepted and will work similarly to how \'depth\' usually works. For example, -1 will insert the message right before the last message in chat.',
329329 typeList: [ARGUMENT_TYPE.NUMBER],
330330 enumProvider: commonEnumProviders.messages({ allowIdAfter: true }),
331331 }),
@@ -388,7 +388,7 @@ export function initDefaultSlashCommands() {
388388 ),
389389 SlashCommandNamedArgument.fromProps({
390390 name: 'at',
391391 description: 'position to insert the message (index-based, corresponding to message id). If not set, the message will be inserted at the end of the chat.\nNegative values (including -0) are accepted and will work similarly to how \'depth\' usually works. For example, -1 will insert the message right before the last message in chat.',
392392 typeList: [ARGUMENT_TYPE.NUMBER],
393393 enumProvider: commonEnumProviders.messages({ allowIdAfter: true }),
394394 }),
@@ -606,7 +606,7 @@ export function initDefaultSlashCommands() {
606606 ),
607607 SlashCommandNamedArgument.fromProps({
608608 name: 'at',
609609 description: 'position to insert the message (index-based, corresponding to message id). If not set, the message will be inserted at the end of the chat.\nNegative values (including -0) are accepted and will work similarly to how \'depth\' usually works. For example, -1 will insert the message right before the last message in chat.',
610610 typeList: [ARGUMENT_TYPE.NUMBER],
611611 enumProvider: commonEnumProviders.messages({ allowIdAfter: true }),
612612 }),
@@ -3025,7 +3025,7 @@ async function sendUserMessageCallback(args, text) {
30253025 let insertAt = Number(args?.at);
30263026
30273027 // Convert possible depth parameter to index
30283028 if (!isNaN(insertAt) && (insertAt < 0 || Object.is(insertAt ===, Number(-0))) {
30293029 // Negative value means going back from current chat length. (E.g.: 8 messages, Depth 1 means insert at index 7)
30303030 insertAt = chat.length + insertAt;
30313031 }
@@ -3399,7 +3399,7 @@ export async function sendMessageAs(args, text) {
33993399 let insertAt = Number(args.at);
34003400
34013401 // Convert possible depth parameter to index
34023402 if (!isNaN(insertAt) && (insertAt < 0 || Object.is(insertAt ===, Number(-0))) {
34033403 // Negative value means going back from current chat length. (E.g.: 8 messages, Depth 1 means insert at index 7)
34043404 insertAt = chat.length + insertAt;
34053405 }
@@ -3453,7 +3453,7 @@ export async function sendNarratorMessage(args, text) {
34533453 let insertAt = Number(args.at);
34543454
34553455 // Convert possible depth parameter to index
34563456 if (!isNaN(insertAt) && (insertAt < 0 || Object.is(insertAt ===, Number(-0))) {
34573457 // Negative value means going back from current chat length. (E.g.: 8 messages, Depth 1 means insert at index 7)
34583458 insertAt = chat.length + insertAt;
34593459 }
@@ -3542,7 +3542,7 @@ async function sendCommentMessage(args, text) {
35423542 let insertAt = Number(args.at);
35433543
35443544 // Convert possible depth parameter to index
35453545 if (!isNaN(insertAt) && (insertAt < 0 || Object.is(insertAt ===, Number(-0))) {
35463546 // Negative value means going back from current chat length. (E.g.: 8 messages, Depth 1 means insert at index 7)
35473547 insertAt = chat.length + insertAt;
35483548 }