diff --git a/package.json b/package.json
index c44dfe0..17d6c7a 100644
--- a/package.json
+++ b/package.json
@@ -54,6 +54,7 @@
"views": {
"debug": [
{
+ "type": "webview",
"id": "helios.runView",
"name": "Helios Runner"
}
diff --git a/src/index.ts b/src/index.ts
index 00911a7..2efeada 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -1,7 +1,9 @@
import {
ExtensionContext,
window,
- commands
+ commands,
+ workspace,
+ TextDocument
} from "vscode"
import {
@@ -24,6 +26,13 @@ export function activate(context: ExtensionContext) {
const cache = new Cache()
const runViewProvider = new RunViewProvider(context, cache)
+ const updateFiles = () => {
+ const files = workspace.textDocuments
+ .filter(doc => isHeliosExt(doc.fileName))
+ .map(doc => doc.fileName)
+ runViewProvider.setFileList(files)
+ }
+
/*languages.registerDocumentFormattingEditProvider('helios', {
provideDocumentFormattingEdits: (document) => {
const firstLine = document.lineAt(0);
@@ -41,6 +50,8 @@ export function activate(context: ExtensionContext) {
window.registerWebviewViewProvider(RunViewProvider.viewType, runViewProvider)
)
+ updateFiles()
+
context.subscriptions.push(
commands.registerCommand("helios.showRunView", () => runViewProvider.reveal())
)
@@ -61,6 +72,23 @@ export function activate(context: ExtensionContext) {
}
runViewProvider.reveal()
}
+ updateFiles()
+ })
+ )
+
+ context.subscriptions.push(
+ workspace.onDidOpenTextDocument(doc => {
+ if (isHeliosExt(doc.fileName)) {
+ updateFiles()
+ }
+ })
+ )
+
+ context.subscriptions.push(
+ workspace.onDidCloseTextDocument(doc => {
+ if (isHeliosExt(doc.fileName)) {
+ updateFiles()
+ }
})
)
}
diff --git a/src/runView.ts b/src/runView.ts
index ded0bd6..6ef83e4 100644
--- a/src/runView.ts
+++ b/src/runView.ts
@@ -6,10 +6,13 @@ import {
CancellationToken,
commands,
window,
- debug
+ debug,
+ workspace,
+ TextDocument
} from "vscode"
import { createRequire } from "module"
+import * as path from "path"
import { Cache } from "./cache"
import { isHeliosExt } from "./repository"
@@ -37,7 +40,7 @@ export class RunViewProvider implements WebviewViewProvider {
webviewView.webview.html = this.html()
webviewView.webview.onDidReceiveMessage(async msg => {
if (msg.command == "run") {
- await this.run(msg.validator, msg.input)
+ await this.run(msg.file, msg.input)
}
})
}
@@ -56,6 +59,13 @@ export class RunViewProvider implements WebviewViewProvider {
}
}
+ setFileList(files: string[]) {
+ if (this.#view) {
+ const mapped = files.map(f => ({ path: f, name: path.basename(f) }))
+ this.#view.webview.postMessage({ command: "setFiles", files: mapped })
+ }
+ }
+
private html(): string {
const nonce = Date.now().toString()
return `
@@ -66,6 +76,8 @@ export class RunViewProvider implements WebviewViewProvider {
textarea { width: 100%; height: 60px; }
input { width: 100%; }
+
+
@@ -76,6 +88,7 @@ export class RunViewProvider implements WebviewViewProvider {
document.getElementById('run').addEventListener('click', () => {
vscode.postMessage({
command: 'run',
+ file: document.getElementById('file').value,
validator: document.getElementById('validator').value,
input: document.getElementById('input').value
});
@@ -85,20 +98,40 @@ export class RunViewProvider implements WebviewViewProvider {
if (m.command === 'setValidator') {
document.getElementById('validator').value = m.validator;
}
+ if (m.command === 'setFiles') {
+ const sel = document.getElementById('file');
+ while (sel.firstChild) sel.removeChild(sel.firstChild);
+ m.files.forEach((f) => {
+ const opt = document.createElement('option');
+ opt.value = f.path;
+ opt.textContent = f.name;
+ sel.appendChild(opt);
+ });
+ }
});