src/vs/workbench/contrib/terminal/browser/links/terminalLinkHelpers.ts/updateLinkWithRelativeCwd
export function updateLinkWithRelativeCwd(capabilities: ITerminalCapabilityStore, y: number, text: string, pathSeparator: string): string | undefined {
	const cwd = capabilities.get(TerminalCapability.CommandDetection)?.getCwdForLine(y);
	if (!cwd) {
		return undefined;
	}
	if (!text.includes(pathSeparator)) {
		text = cwd + pathSeparator + text;
	} else {
		let commonDirs = 0;
		let i = 0;
		const cwdPath = cwd.split(pathSeparator).reverse();
		const linkPath = text.split(pathSeparator);
		while (i < cwdPath.length) {
			if (cwdPath[i] === linkPath[i]) {
				commonDirs++;
			}
			i++;
		}
		text = cwd + pathSeparator + linkPath.slice(commonDirs).join(pathSeparator);
	}
	return text;
}