Skip to content

Commit b5f61ff

Browse files
Disable launcher.bat script to unblock Git Bash users if windows user name has blank spaces
Signed-off-by: Jinbo Wang <[email protected]>
1 parent 9be9832 commit b5f61ff

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

‎src/configurationProvider.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,10 @@ export class JavaDebugConfigurationProvider implements vscode.DebugConfiguration
307307
}
308308

309309
if (process.platform === "win32" && config.console !== "internalConsole") {
310-
config.launcherScript = utility.getLauncherScriptPath();
310+
const launcherScript: string = utility.getLauncherScriptPath();
311+
if (!launcherScript.includes(" ") || !utility.isGitBash(config.console === "integratedTerminal")) {
312+
config.launcherScript = launcherScript;
313+
}
311314
}
312315
} else if (config.request === "attach") {
313316
if (config.hostName && config.port) {

‎src/utility.ts‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,18 @@ export function getLauncherScriptPath() {
215215
return path.join(ext.extensionPath, "scripts", "launcher.bat");
216216
}
217217

218+
export function isGitBash(isIntegratedTerminal: boolean): boolean {
219+
const terminal: vscode.WorkspaceConfiguration = vscode.workspace.getConfiguration("terminal");
220+
const shellPath: string | undefined = isIntegratedTerminal ? terminal?.get("integrated.shell.windows") : terminal?.get("external.windowsExec");
221+
if (!shellPath) {
222+
return false;
223+
}
224+
225+
const candidates: string[] = ["Git\\bin\\bash.exe", "Git\\bin\\bash", "Git\\usr\\bin\\bash.exe", "Git\\usr\\bin\\bash"];
226+
const find: string | undefined = candidates.find((candidate: string) => shellPath.endsWith(candidate));
227+
return !!find;
228+
}
229+
218230
export enum ServerMode {
219231
STANDARD = "Standard",
220232
LIGHTWEIGHT = "LightWeight",

0 commit comments

Comments
 (0)