diff --git a/src/da/activate.ts b/src/da/activate.ts index 9e8d6f7..e8d04be 100644 --- a/src/da/activate.ts +++ b/src/da/activate.ts @@ -1,5 +1,6 @@ import * as vscode from "vscode"; +import { existsSync, getInputPath } from "../extension"; import { regalPath } from "./../ls/clients/regal"; import { promptForUpdateRegal } from "./../ls/clients/regal"; import * as opa from "./../opa"; @@ -13,6 +14,13 @@ export function activateDebugger(context: vscode.ExtensionContext) { if (!targetResource && vscode.window.activeTextEditor) { targetResource = vscode.window.activeTextEditor.document.uri; } + + // Only add the inputPath if the file exists + let inputPath: string | undefined = getInputPath(); + if (!existsSync(inputPath)) { + inputPath = undefined; + } + if (targetResource) { vscode.debug.startDebugging(undefined, { type: "opa-debug", @@ -20,6 +28,8 @@ export function activateDebugger(context: vscode.ExtensionContext) { request: "launch", command: "eval", query: "data", + inputPath: inputPath, + stopOnEntry: true, enablePrint: true, }); } diff --git a/src/extension.ts b/src/extension.ts index deef4e4..6f2cff0 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -685,7 +685,7 @@ function checkOnSaveEnabled() { return vscode.workspace.getConfiguration("opa").get("checkOnSave"); } -function existsSync(path: string): boolean { +export function existsSync(path: string): boolean { const parsed = vscode.Uri.parse(path); if (parsed.scheme === "file") { @@ -695,7 +695,7 @@ function existsSync(path: string): boolean { return fs.existsSync(path); } -function getInputPath(): string { +export function getInputPath(): string { // look for input.json at the active editor's directory, or the workspace directory const activeDir = path.dirname(vscode.window.activeTextEditor!.document.uri.fsPath);