diff --git a/scripts/launcher.bat b/scripts/launcher.bat new file mode 100644 index 0000000..10617f9 --- /dev/null +++ b/scripts/launcher.bat @@ -0,0 +1,7 @@ +@echo off + +REM Change code page to UTF-8 for better compatibility. +@chcp.com 65001 > NUL + +REM Execute real command passed by args +%* diff --git a/src/configurationProvider.ts b/src/configurationProvider.ts index f1b9d45..534ed23 100644 --- a/src/configurationProvider.ts +++ b/src/configurationProvider.ts @@ -237,6 +237,10 @@ export class JavaDebugConfigurationProvider implements vscode.DebugConfiguration config.shortenCommandLine = await detectLaunchCommandStyle(config); } + if (process.platform === "win32" && config.request === "launch" && config.console !== "internalConsole") { + config.launcherScript = utility.getLauncherScriptPath(); + } + const debugServerPort = await lsPlugin.startDebugSession(); if (debugServerPort) { config.debugServer = debugServerPort; diff --git a/src/utility.ts b/src/utility.ts index e317ca2..9eafef1 100644 --- a/src/utility.ts +++ b/src/utility.ts @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. +import * as path from "path"; import * as vscode from "vscode"; import { setUserError } from "vscode-extension-telemetry-wrapper"; import { logger, Type } from "./logger"; @@ -8,6 +9,7 @@ import { logger, Type } from "./logger"; const TROUBLESHOOTING_LINK = "https://github.com/Microsoft/vscode-java-debug/blob/master/Troubleshooting.md"; const LEARN_MORE = "Learn More"; const JAVA_EXTENSION_ID = "redhat.java"; +const DEBUGGER_EXTENSION_ID = "vscjava.vscode-java-debug"; export class UserError extends Error { public context: ITroubleshootingMessage; @@ -158,3 +160,8 @@ export function isJavaExtEnabled(): boolean { const javaExt = vscode.extensions.getExtension(JAVA_EXTENSION_ID); return !!javaExt; } + +export function getLauncherScriptPath() { + const ext = vscode.extensions.getExtension(DEBUGGER_EXTENSION_ID); + return path.join(ext.extensionPath, "scripts", "launcher.bat"); +}