From 967371133d9a7c95a3f59e08ac3e47afc937ba3b Mon Sep 17 00:00:00 2001 From: Christian Jorgensen Date: Tue, 20 Jun 2023 22:22:41 +0200 Subject: [PATCH 1/5] Prompt multiple commands in Action --- src/api/CompileTools.ts | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/api/CompileTools.ts b/src/api/CompileTools.ts index 95b4cea57..350991c47 100644 --- a/src/api/CompileTools.ts +++ b/src/api/CompileTools.ts @@ -557,10 +557,19 @@ export namespace CompileTools { getDefaultVariables(instance, ileSetup) ); - if (commandString.startsWith(`?`)) { - commandString = await vscode.window.showInputBox({ prompt: `Run Command`, value: commandString.substring(1) }) || ''; - } else { - commandString = await showCustomInputs(`Run Command`, commandString, title); + if (commandString) { + const commands = commandString.split(`\n`).filter(command => command.trim().length > 0); + let promptedCommands = []; + for (let command of commands) { + if (command.startsWith(`?`)) { + command = await vscode.window.showInputBox({ prompt: `Run Command`, value: command.substring(1) }) || ''; + } else { + command = await showCustomInputs(`Run Command`, command, title); + } + promptedCommands.push(command); + if (!command) break; + } + commandString = !promptedCommands.includes(``) ? promptedCommands.join(`\n`) : ``; } if (commandString) { From 0a7deb1d57ff6b0b2baadd0c4f2eebbec2eb3d4b Mon Sep 17 00:00:00 2001 From: Christian Jorgensen Date: Tue, 20 Jun 2023 22:23:30 +0200 Subject: [PATCH 2/5] Fix typo --- src/api/CompileTools.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/api/CompileTools.ts b/src/api/CompileTools.ts index 350991c47..59a2497a1 100644 --- a/src/api/CompileTools.ts +++ b/src/api/CompileTools.ts @@ -679,11 +679,11 @@ export namespace CompileTools { if (end >= 0) { let currentInput = command.substring(start + 2, end); - const [name, label, initalValue] = currentInput.split(`|`); + const [name, label, initialValue] = currentInput.split(`|`); components.push({ name, label, - initialValue: initalValue || ``, + initialValue: initialValue || ``, start, end: end + 1 }); From 91b1d818c3dbb0381e56074cb1901a4c7c4bbe89 Mon Sep 17 00:00:00 2001 From: Christian Jorgensen Date: Tue, 20 Jun 2023 22:54:31 +0200 Subject: [PATCH 3/5] Add `Cancel` button on Custom Inputs panel --- src/api/CompileTools.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/api/CompileTools.ts b/src/api/CompileTools.ts index 59a2497a1..6dcf96c9c 100644 --- a/src/api/CompileTools.ts +++ b/src/api/CompileTools.ts @@ -719,12 +719,12 @@ export namespace CompileTools { } } - commandUI.addButtons({ id: `execute`, label: `Execute` }); + commandUI.addButtons({ id: `execute`, label: `Execute` }, { id: `cancel`, label: `Cancel` }); const page = await commandUI.loadPage(name); if (page) { page.panel.dispose(); - if (page.data) { + if (page.data && page.data.buttons !== `cancel`) { const dataEntries = Object.entries(page.data); for (const component of components.reverse()) { const value = dataEntries.find(([key]) => key === component.name)?.[1]; From 893bb6385c20ef3b0ae1f56981c648ad73d42bb1 Mon Sep 17 00:00:00 2001 From: Christian Jorgensen Date: Wed, 21 Jun 2023 11:42:15 +0200 Subject: [PATCH 4/5] Make promptedCommands array immutable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Sébastien Julliand --- src/api/CompileTools.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/CompileTools.ts b/src/api/CompileTools.ts index 6dcf96c9c..c7bfba8fd 100644 --- a/src/api/CompileTools.ts +++ b/src/api/CompileTools.ts @@ -559,7 +559,7 @@ export namespace CompileTools { if (commandString) { const commands = commandString.split(`\n`).filter(command => command.trim().length > 0); - let promptedCommands = []; + const promptedCommands = []; for (let command of commands) { if (command.startsWith(`?`)) { command = await vscode.window.showInputBox({ prompt: `Run Command`, value: command.substring(1) }) || ''; From 60c52ec2a3f3e261fb02faef18c55869081686cb Mon Sep 17 00:00:00 2001 From: Christian Jorgensen Date: Wed, 21 Jun 2023 11:48:26 +0200 Subject: [PATCH 5/5] Fix eslint problem for `loadPage` and `buttons` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Sébastien Julliand --- src/api/CompileTools.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/CompileTools.ts b/src/api/CompileTools.ts index c7bfba8fd..817e05220 100644 --- a/src/api/CompileTools.ts +++ b/src/api/CompileTools.ts @@ -721,7 +721,7 @@ export namespace CompileTools { commandUI.addButtons({ id: `execute`, label: `Execute` }, { id: `cancel`, label: `Cancel` }); - const page = await commandUI.loadPage(name); + const page = await commandUI.loadPage(name); if (page) { page.panel.dispose(); if (page.data && page.data.buttons !== `cancel`) {