From 52bedc830d8fea94d0f6398f003d3092c3070085 Mon Sep 17 00:00:00 2001 From: Shaked Kaplan Date: Sun, 7 Apr 2024 15:42:43 +0300 Subject: [PATCH] allow to run main objects of different files in parallel --- packages/metals-vscode/src/debugger/scalaDebugger.ts | 6 +++--- packages/metals-vscode/src/util.ts | 5 +++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/metals-vscode/src/debugger/scalaDebugger.ts b/packages/metals-vscode/src/debugger/scalaDebugger.ts index a8d337672..30dea3aa4 100644 --- a/packages/metals-vscode/src/debugger/scalaDebugger.ts +++ b/packages/metals-vscode/src/debugger/scalaDebugger.ts @@ -17,7 +17,7 @@ import { } from "metals-languageclient"; import { ExtendedScalaRunMain, ScalaCodeLensesParams } from "./types"; import { platform } from "os"; -import { currentWorkspaceFolder } from "../util"; +import { currentFile, currentWorkspaceFolder } from "../util"; const configurationType = "scala"; @@ -76,10 +76,10 @@ async function runMain(main: ExtendedScalaRunMain): Promise { }, {} ); - + const file = currentFile(); const shellOptions = { ...platformSpecificOptions(), env }; const task = new Task( - { type: "scala", task: "run" }, + { type: "scala" + (file ? `: ${file.fileName}` : ""), task: "run" }, workspaceFolder, "Scala run", "Metals", diff --git a/packages/metals-vscode/src/util.ts b/packages/metals-vscode/src/util.ts index baa982a00..2e5ca27f4 100644 --- a/packages/metals-vscode/src/util.ts +++ b/packages/metals-vscode/src/util.ts @@ -7,6 +7,7 @@ import { window, workspace, WorkspaceFolder, + TextDocument, } from "vscode"; import { ExecuteCommandRequest, @@ -70,6 +71,10 @@ export function currentWorkspaceFolder(): WorkspaceFolder | undefined { return workspace.workspaceFolders?.[0]; } +export function currentFile(): TextDocument | undefined { + return window.activeTextEditor?.document; +} + export function getTextDocumentPositionParams( editor: TextEditor ): TextDocumentPositionParams {