mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-28 04:23:32 +01:00
Git - improvements to relative path calculation (#245001)
Git - relative path using both the repository root and repository real root
This commit is contained in:
@@ -328,6 +328,10 @@ export function pathEquals(a: string, b: string): boolean {
|
||||
* casing which is why we attempt to use substring() before relative().
|
||||
*/
|
||||
export function relativePath(from: string, to: string): string {
|
||||
return relativePathWithNoFallback(from, to) ?? relative(from, to);
|
||||
}
|
||||
|
||||
export function relativePathWithNoFallback(from: string, to: string): string | undefined {
|
||||
// There are cases in which the `from` path may contain a trailing separator at
|
||||
// the end (ex: "C:\", "\\server\folder\" (Windows) or "/" (Linux/macOS)) which
|
||||
// is by design as documented in https://github.com/nodejs/node/issues/1765. If
|
||||
@@ -340,8 +344,7 @@ export function relativePath(from: string, to: string): string {
|
||||
return to.substring(from.length);
|
||||
}
|
||||
|
||||
// Fallback to `path.relative`
|
||||
return relative(from, to);
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export function* splitInChunks(array: string[], maxChunkLength: number): IterableIterator<string[]> {
|
||||
|
||||
Reference in New Issue
Block a user