Skip to content

Commit b2a4831

Browse files
Disable launcher.bat script to unblock Git Bash users if windows username has blank spaces (#938)
* Disable launcher.bat script to unblock Git Bash users if windows user name has blank spaces Signed-off-by: Jinbo Wang <jinbwan@microsoft.com> * Use vscode.env.shell API to get current shell
1 parent e3c99ec commit b2a4831

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 currentWindowsShellPath: string | undefined = isIntegratedTerminal ? vscode.env.shell :
220+
vscode.workspace.getConfiguration("terminal")?.get("external.windowsExec");
221+
if (!currentWindowsShellPath) {
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) => currentWindowsShellPath.endsWith(candidate));
227+
return !!find;
228+
}
229+
218230
export enum ServerMode {
219231
STANDARD = "Standard",
220232
LIGHTWEIGHT = "LightWeight",

0 commit comments

Comments
 (0)