From 1906ca34c1fb716be149aa25869bf1480c5d3b6b Mon Sep 17 00:00:00 2001 From: Johan Fylling Date: Wed, 11 Sep 2024 16:08:04 +0200 Subject: [PATCH 1/2] Inferring input.json location for debug workspace launcher And enabling 'stopOnEntry' by default. Signed-off-by: Johan Fylling --- src/da/activate.ts | 10 ++++++++++ src/extension.ts | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/da/activate.ts b/src/da/activate.ts index 9e8d6f7..660c241 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 + var inputPath = getInputPath(); + if (!existsSync(inputPath)) { + inputPath = ""; + } + 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); From cc99880016ce8157cfc0d3483f9fdaa80053f76b Mon Sep 17 00:00:00 2001 From: Johan Fylling Date: Thu, 12 Sep 2024 10:35:27 +0200 Subject: [PATCH 2/2] setting inputPath to undefined if no input.json is found Signed-off-by: Johan Fylling --- src/da/activate.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/da/activate.ts b/src/da/activate.ts index 660c241..e8d04be 100644 --- a/src/da/activate.ts +++ b/src/da/activate.ts @@ -16,9 +16,9 @@ export function activateDebugger(context: vscode.ExtensionContext) { } // Only add the inputPath if the file exists - var inputPath = getInputPath(); + let inputPath: string | undefined = getInputPath(); if (!existsSync(inputPath)) { - inputPath = ""; + inputPath = undefined; } if (targetResource) {