From e9b4ec74d3c746b8a976bdee1d41839c49d70b12 Mon Sep 17 00:00:00 2001 From: Megan Rogge Date: Tue, 21 Sep 2021 12:23:58 -0700 Subject: [PATCH] fix #133539 --- .../terminal/browser/terminalInstance.ts | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts b/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts index a856702ea8a..3a37b5745cd 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts @@ -2319,12 +2319,33 @@ export class TerminalLabelComputer extends Disposable { return this._instance.staticTitle.replace(/[\n\r\t]/g, '') || templateProperties.process?.replace(/[\n\r\t]/g, '') || ''; } const detection = this._instance.capabilities.includes(ProcessCapability.CwdDetection); - const zeroRootWorkspace = this._workspaceContextService.getWorkspace().folders.length === 0 && templateProperties.cwd === (this._instance.userHome || this._configHelper.config.cwd); - const singleRootWorkspace = this._workspaceContextService.getWorkspace().folders.length === 1 && templateProperties.cwd === (this._configHelper.config.cwd || this._workspaceContextService.getWorkspace().folders[0]?.uri.fsPath); + const zeroRootWorkspace = this._workspaceContextService.getWorkspace().folders.length === 0 && this.pathsEqual(templateProperties.cwd, this._instance.userHome || this._configHelper.config.cwd); + const singleRootWorkspace = this._workspaceContextService.getWorkspace().folders.length === 1 && this.pathsEqual(templateProperties.cwd, this._configHelper.config.cwd || this._workspaceContextService.getWorkspace().folders[0]?.uri.fsPath); templateProperties.cwdFolder = (!templateProperties.cwd || !detection || zeroRootWorkspace || singleRootWorkspace) ? '' : path.basename(templateProperties.cwd); //Remove special characters that could mess with rendering const label = template(labelTemplate, (templateProperties as unknown) as { [key: string]: string | ISeparator | undefined | null; }).replace(/[\n\r\t]/g, ''); return label === '' && labelType === TerminalLabelType.Title ? (this._instance.processName || '') : label; } + + pathsEqual(path1?: string | null, path2?: string) { + if (!path1 && !path2) { + return true; + } else if (!path1 || !path2) { + return false; + } else if (path1 === path2) { + return true; + } + const split1 = path1.includes('/') ? path1.split('/') : path1.split('\\'); + const split2 = path2.includes('/') ? path2.split('/') : path2.split('\\'); + if (split1.length !== split2.length) { + return false; + } + for (let i = 0; i < path1.length; i++) { + if (path1[i] !== path2[i]) { + return false; + } + } + return true; + } } -- GitLab