Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow to run main of different files in parallel #1479

Merged
merged 2 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/metals-vscode/src/debugger/scalaDebugger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -76,10 +76,10 @@ async function runMain(main: ExtendedScalaRunMain): Promise<boolean> {
},
{}
);

const file = currentFile();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might prove problematic if we run but the file is not focused 🤔

Actually, we can already make it better via main.class which will be the name of the class being run, which should be unique.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. testing it now.

const shellOptions = { ...platformSpecificOptions(), env };
const task = new Task(
{ type: "scala", task: "run" },
{ type: "scala" + (file ? `: ${file.fileName}` : ""), task: "run" },
workspaceFolder,
"Scala run",
"Metals",
Expand Down
5 changes: 5 additions & 0 deletions packages/metals-vscode/src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
window,
workspace,
WorkspaceFolder,
TextDocument,
} from "vscode";
import {
ExecuteCommandRequest,
Expand Down Expand Up @@ -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 {
Expand Down
Loading