MCPcopy Create free account
hub / github.com/deepnote/vscode-deepnote / getDisplayPathImpl

Function getDisplayPathImpl

src/platform/common/platform/fs-paths.ts:88–108  ·  view source on GitHub ↗
(file: Uri | undefined, cwd: Uri | undefined, homePath: Uri | undefined)

Source from the content-addressed store, hash-verified

86}
87
88function getDisplayPathImpl(file: Uri | undefined, cwd: Uri | undefined, homePath: Uri | undefined): string {
89 const isWindows = getOSType() === OSType.Windows;
90 if (file && cwd && uriPath.isEqualOrParent(file, cwd, true)) {
91 const relativePath = uriPath.relativePath(cwd, file);
92 if (relativePath) {
93 // On windows relative path will still use forwardslash because uriPath.relativePath is a URI path
94 return isWindows ? relativePath.replace(/\//g, '\\') : relativePath;
95 }
96 }
97
98 if (file && homePath && uriPath.isEqualOrParent(file, homePath, true)) {
99 let relativePath = uriPath.relativePath(homePath, file);
100 if (relativePath) {
101 // On windows relative path will still use forwardslash because uriPath.relativePath is a URI path
102 relativePath = isWindows ? relativePath.replace(/\//g, '\\') : relativePath;
103 return `~${path.sep}${relativePath}`;
104 }
105 }
106
107 return getFilePath(file);
108}

Callers 1

getDisplayPathFunction · 0.85

Calls 5

getOSTypeFunction · 0.90
getFilePathFunction · 0.70
isEqualOrParentMethod · 0.65
relativePathMethod · 0.65
replaceMethod · 0.45

Tested by

no test coverage detected