未验证 提交 e9b4ec74 编写于 作者: M Megan Rogge

fix #133539

上级 d56f8ff2
......@@ -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;
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册