diff --git a/package.json b/package.json index ee18c2a..ec10140 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "juvix-mode", - "version": "0.1.11", + "version": "0.1.12", "license": "GPL-3.0", "description": "Juvix IDE support for VSCode", "displayName": "Juvix", @@ -307,6 +307,11 @@ "when": "editorLangId == Juvix && editorTextFocus", "icon" : "$(run)" }, + { + "command": "juvix-mode.openRepl", + "title": "Open REPL", + "category": "Juvix" + }, { "command": "juvix-mode.loadFileRepl", "title": "Load file in REPL", diff --git a/src/repl.ts b/src/repl.ts index 2e6a4e0..165bc77 100644 --- a/src/repl.ts +++ b/src/repl.ts @@ -154,6 +154,34 @@ export class JuvixRepl { } export async function activate(context: vscode.ExtensionContext) { + + const justOpenREPL = vscode.commands.registerCommand( + 'juvix-mode.openRepl', + () => { + const document = vscode.window.activeTextEditor?.document; + if (document) { let repl = juvixTerminals.get(document.fileName); + if (!repl || repl.notAvailable()) { + repl?.dispose(); + repl = new JuvixRepl(document); + } + } else { + const tempTerminal = vscode.window.createTerminal( + { + name: terminalName, + isTransient: false, + shellPath: '/usr/bin/bash', + location: { + viewColumn: vscode.ViewColumn.Beside, + preserveFocus: true, + } + }) + tempTerminal.show(); + tempTerminal.sendText('juvix repl'); + context.subscriptions.push( + tempTerminal + ); + } + }); /* Create a new terminal and send the command to load the current file */ const loadFile = vscode.commands.registerCommand( 'juvix-mode.loadFileRepl',