Skip to content

Commit 07ce6f7

Browse files
authored
Use a bat launcher to set page code (#625)
1 parent 6c8fed7 commit 07ce6f7

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

scripts/launcher.bat

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
@echo off
2+
3+
REM Change code page to UTF-8 for better compatibility.
4+
@chcp.com 65001 > NUL
5+
6+
REM Execute real command passed by args
7+
%*

src/configurationProvider.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,10 @@ export class JavaDebugConfigurationProvider implements vscode.DebugConfiguration
237237
config.shortenCommandLine = await detectLaunchCommandStyle(config);
238238
}
239239

240+
if (process.platform === "win32" && config.request === "launch" && config.console !== "internalConsole") {
241+
config.launcherScript = utility.getLauncherScriptPath();
242+
}
243+
240244
const debugServerPort = await lsPlugin.startDebugSession();
241245
if (debugServerPort) {
242246
config.debugServer = debugServerPort;

src/utility.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT license.
33

4+
import * as path from "path";
45
import * as vscode from "vscode";
56
import { setUserError } from "vscode-extension-telemetry-wrapper";
67
import { logger, Type } from "./logger";
78

89
const TROUBLESHOOTING_LINK = "https://github.com/Microsoft/vscode-java-debug/blob/master/Troubleshooting.md";
910
const LEARN_MORE = "Learn More";
1011
const JAVA_EXTENSION_ID = "redhat.java";
12+
const DEBUGGER_EXTENSION_ID = "vscjava.vscode-java-debug";
1113

1214
export class UserError extends Error {
1315
public context: ITroubleshootingMessage;
@@ -158,3 +160,8 @@ export function isJavaExtEnabled(): boolean {
158160
const javaExt = vscode.extensions.getExtension(JAVA_EXTENSION_ID);
159161
return !!javaExt;
160162
}
163+
164+
export function getLauncherScriptPath() {
165+
const ext = vscode.extensions.getExtension(DEBUGGER_EXTENSION_ID);
166+
return path.join(ext.extensionPath, "scripts", "launcher.bat");
167+
}

0 commit comments

Comments
 (0)