Skip to content

Commit

Permalink
Fix VSC working directory location.
Browse files Browse the repository at this point in the history
Co-authored-by: fewizz <hazeevaidar@gmail.com>
  • Loading branch information
modmuss50 and fewizz committed Jan 26, 2025
1 parent 9bcce94 commit 1c02578
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/main/java/net/fabricmc/loom/task/GenVsCodeProjectTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ public void genRuns() throws IOException {
}

for (VsCodeConfiguration configuration : getLaunchConfigurations().get()) {
final JsonElement configurationJson = LoomGradlePlugin.GSON.toJsonTree(configuration);
JsonObject configurationJson = LoomGradlePlugin.GSON.toJsonTree(configuration).getAsJsonObject();
configurationJson.remove("runDir");

final List<JsonElement> toRemove = new LinkedList<>();

Expand Down Expand Up @@ -161,19 +162,22 @@ public record VsCodeConfiguration(
String projectName,
String runDir) implements Serializable {
public static VsCodeConfiguration fromRunConfig(Project project, RunConfig runConfig) {
Path rootPath = project.getRootDir().toPath();
Path projectPath = project.getProjectDir().toPath();
String relativeRunDir = rootPath.relativize(projectPath).resolve(runConfig.runDir).toString();
return new VsCodeConfiguration(
"java",
runConfig.configName,
"launch",
"${workspaceFolder}/" + runConfig.runDir,
"${workspaceFolder}/" + relativeRunDir,
"integratedTerminal",
false,
runConfig.mainClass,
RunConfig.joinArguments(runConfig.vmArgs),
RunConfig.joinArguments(runConfig.programArgs),
new HashMap<>(runConfig.environmentVariables),
runConfig.projectName,
project.getProjectDir().toPath().resolve(runConfig.runDir).toAbsolutePath().toString()
rootPath.resolve(relativeRunDir).toAbsolutePath().toString()
);
}
}
Expand Down

0 comments on commit 1c02578

Please sign in to comment.