From 557b0086eecb7273c9ac0ff26125ab7760221b7c Mon Sep 17 00:00:00 2001 From: Jinbo Wang Date: Wed, 20 Jan 2021 10:56:13 +0800 Subject: [PATCH 1/2] Disable launcher.bat script to unblock Git Bash users if windows user name has blank spaces Signed-off-by: Jinbo Wang --- src/configurationProvider.ts | 5 ++++- src/utility.ts | 12 ++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/configurationProvider.ts b/src/configurationProvider.ts index 91882259..17eb273e 100644 --- a/src/configurationProvider.ts +++ b/src/configurationProvider.ts @@ -307,7 +307,10 @@ export class JavaDebugConfigurationProvider implements vscode.DebugConfiguration } if (process.platform === "win32" && config.console !== "internalConsole") { - config.launcherScript = utility.getLauncherScriptPath(); + const launcherScript: string = utility.getLauncherScriptPath(); + if (!launcherScript.includes(" ") || !utility.isGitBash(config.console === "integratedTerminal")) { + config.launcherScript = launcherScript; + } } } else if (config.request === "attach") { if (config.hostName && config.port) { diff --git a/src/utility.ts b/src/utility.ts index 55510f4d..ca676275 100644 --- a/src/utility.ts +++ b/src/utility.ts @@ -215,6 +215,18 @@ export function getLauncherScriptPath() { return path.join(ext.extensionPath, "scripts", "launcher.bat"); } +export function isGitBash(isIntegratedTerminal: boolean): boolean { + const terminal: vscode.WorkspaceConfiguration = vscode.workspace.getConfiguration("terminal"); + const shellPath: string | undefined = isIntegratedTerminal ? terminal?.get("integrated.shell.windows") : terminal?.get("external.windowsExec"); + if (!shellPath) { + return false; + } + + const candidates: string[] = ["Git\\bin\\bash.exe", "Git\\bin\\bash", "Git\\usr\\bin\\bash.exe", "Git\\usr\\bin\\bash"]; + const find: string | undefined = candidates.find((candidate: string) => shellPath.endsWith(candidate)); + return !!find; +} + export enum ServerMode { STANDARD = "Standard", LIGHTWEIGHT = "LightWeight", From 07ed6df3fd64901fbc662a27b0a002c2f5fad55d Mon Sep 17 00:00:00 2001 From: Jinbo Wang Date: Wed, 20 Jan 2021 17:04:22 +0800 Subject: [PATCH 2/2] Use vscode.env.shell API to get current shell --- src/utility.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/utility.ts b/src/utility.ts index ca676275..377cb0a0 100644 --- a/src/utility.ts +++ b/src/utility.ts @@ -216,14 +216,14 @@ export function getLauncherScriptPath() { } export function isGitBash(isIntegratedTerminal: boolean): boolean { - const terminal: vscode.WorkspaceConfiguration = vscode.workspace.getConfiguration("terminal"); - const shellPath: string | undefined = isIntegratedTerminal ? terminal?.get("integrated.shell.windows") : terminal?.get("external.windowsExec"); - if (!shellPath) { + const currentWindowsShellPath: string | undefined = isIntegratedTerminal ? vscode.env.shell : + vscode.workspace.getConfiguration("terminal")?.get("external.windowsExec"); + if (!currentWindowsShellPath) { return false; } const candidates: string[] = ["Git\\bin\\bash.exe", "Git\\bin\\bash", "Git\\usr\\bin\\bash.exe", "Git\\usr\\bin\\bash"]; - const find: string | undefined = candidates.find((candidate: string) => shellPath.endsWith(candidate)); + const find: string | undefined = candidates.find((candidate: string) => currentWindowsShellPath.endsWith(candidate)); return !!find; }