From 6f712bed8ceb30aaff256c5efe690b1ffd7be5b2 Mon Sep 17 00:00:00 2001 From: Davy Landman Date: Fri, 27 Sep 2024 10:56:26 +0200 Subject: [PATCH] Allow the user to start the REPL after warning about a possible misconfiguration Fixes #435 --- rascal-vscode-extension/src/RascalExtension.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/rascal-vscode-extension/src/RascalExtension.ts b/rascal-vscode-extension/src/RascalExtension.ts index 881856341..6db65bca4 100644 --- a/rascal-vscode-extension/src/RascalExtension.ts +++ b/rascal-vscode-extension/src/RascalExtension.ts @@ -121,8 +121,9 @@ export class RascalExtension implements vscode.Disposable { if (uri) { const [error, detail] = await this.verifyProjectSetup(uri); if (error !== '') { - await this.reportTerminalStartError(error, detail, {showOutput : false}); - return; + if (!await this.reportTerminalStartError(error, detail, {showOutput : false, canContinue: true})) { + return; + } } } progress.report({increment: 20, message: "Requesting IDE configuration"}); @@ -143,23 +144,28 @@ export class RascalExtension implements vscode.Disposable { progress.report({increment: 25, message: "Finished creating terminal"}); }); } catch (err) { - await this.reportTerminalStartError("Failed to start the Rascal REPL, check Rascal Output Window", "" + err, { showOutput: true}); + await this.reportTerminalStartError("Failed to start the Rascal REPL, check Rascal Output Window", "" + err, { showOutput: true, canContinue: false}); } } - private async reportTerminalStartError(msg: string, detail: string = "", config : {modal?: boolean, showOutput?: boolean}) { + private async reportTerminalStartError(msg: string, detail: string = "", config : {modal?: boolean, showOutput?: boolean, canContinue?: boolean}) : Promise { const options = ["View Documentation"]; if (config.showOutput) { options.push("Show Rascal Output Window"); } - options.push("Ok"); + if (config.canContinue === true) { + options.push("Still start the REPL"); + } const selected = await vscode.window.showErrorMessage(msg, {detail : detail, modal: config.modal ?? true}, ...options); if (selected === "View Documentation") { await vscode.env.openExternal(vscode.Uri.parse("https://www.rascal-mpl.org/docs/GettingStarted/CreateNewProject/")); + return false; } if (selected === "Show Rascal Output Window") { await vscode.commands.executeCommand("workbench.action.output.show.extension-output-usethesource.rascalmpl-#1-Rascal MPL Language Server"); + return false; } + return config.canContinue === true; } async fileExists(f: vscode.Uri) {