From 9b3cd719d789d45b6c666dce6ddb9982dcaff62e Mon Sep 17 00:00:00 2001 From: LenAnderson Date: Thu, 20 Jun 2024 15:52:08 -0400 Subject: [PATCH] track index in getvar replacement --- .../scripts/slash-commands/SlashCommandParser.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/public/scripts/slash-commands/SlashCommandParser.js b/public/scripts/slash-commands/SlashCommandParser.js index a895b028e..2b90c2625 100644 --- a/public/scripts/slash-commands/SlashCommandParser.js +++ b/public/scripts/slash-commands/SlashCommandParser.js @@ -514,11 +514,14 @@ export class SlashCommandParser { } replaceGetvar(value) { - return value.replace(/{{(get(?:global)?var)::([^}]+)}}/gi, (_, cmd, name) => { + return value.replace(/{{(get(?:global)?var)::([^}]+)}}/gi, (match, cmd, name, idx) => { name = name.trim(); + const startIdx = this.index - value.length + idx; + const endIdx = this.index - value.length + idx + match.length; // store pipe const pipeName = `_PARSER_${uuidv4()}`; - const storePipe = new SlashCommandExecutor(null); { + const storePipe = new SlashCommandExecutor(startIdx); { + storePipe.end = endIdx; storePipe.command = this.commands['let']; storePipe.name = 'let'; const nameAss = new SlashCommandUnnamedArgumentAssignment(); @@ -529,7 +532,8 @@ export class SlashCommandParser { this.closure.executorList.push(storePipe); } // getvar / getglobalvar - const getvar = new SlashCommandExecutor(null); { + const getvar = new SlashCommandExecutor(startIdx); { + getvar.end = endIdx; getvar.command = this.commands[cmd]; getvar.name = 'cmd'; const nameAss = new SlashCommandUnnamedArgumentAssignment(); @@ -539,7 +543,8 @@ export class SlashCommandParser { } // set to temp scoped var const varName = `_PARSER_${uuidv4()}`; - const setvar = new SlashCommandExecutor(null); { + const setvar = new SlashCommandExecutor(startIdx); { + setvar.end = endIdx; setvar.command = this.commands['let']; setvar.name = 'let'; const nameAss = new SlashCommandUnnamedArgumentAssignment(); @@ -550,7 +555,8 @@ export class SlashCommandParser { this.closure.executorList.push(setvar); } // return pipe - const returnPipe = new SlashCommandExecutor(null); { + const returnPipe = new SlashCommandExecutor(startIdx); { + returnPipe.end = endIdx; returnPipe.command = this.commands['return']; returnPipe.name = 'return'; const varAss = new SlashCommandUnnamedArgumentAssignment();