From c47db9e7299066b81861a04439fbfaa3a88e54e8 Mon Sep 17 00:00:00 2001 From: LenAnderson Date: Thu, 4 Jul 2024 12:35:56 -0400 Subject: [PATCH] no pipe inject in first executor of closure --- public/scripts/slash-commands/SlashCommandClosure.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/public/scripts/slash-commands/SlashCommandClosure.js b/public/scripts/slash-commands/SlashCommandClosure.js index 12da36cd9..faf7440c1 100644 --- a/public/scripts/slash-commands/SlashCommandClosure.js +++ b/public/scripts/slash-commands/SlashCommandClosure.js @@ -251,6 +251,7 @@ export class SlashCommandClosure { } async * executeStep() { let done = 0; + let isFirst = true; for (const executor of this.executorList) { this.onProgress?.(done, this.commandCount); this.debugController?.setExecutor(executor); @@ -259,10 +260,12 @@ export class SlashCommandClosure { // no execution for breakpoints, just raise counter done++; yield executor; + isFirst = false; } else if (executor instanceof SlashCommandBreak) { done += this.executorList.length - this.executorList.indexOf(executor); this.scope.pipe = executor.value ?? this.scope.pipe; yield executor; + isFirst = false; } else { /**@type {import('./SlashCommand.js').NamedArguments} */ let args = { @@ -302,8 +305,7 @@ export class SlashCommandClosure { // substitute unnamed argument if (executor.unnamedArgumentList.length == 0) { - //TODO no pipe injection on first executor in a closure? - if (executor.injectPipe) { + if (!isFirst && executor.injectPipe) { value = this.scope.pipe; args._hasUnnamedArgument = this.scope.pipe !== null && this.scope.pipe !== undefined; } @@ -383,6 +385,7 @@ export class SlashCommandClosure { } } yield executor; + isFirst = false; } }