Skip to content

Commit ef6de2c

Browse files
Add missing doc comments.
1 parent a383d4c commit ef6de2c

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

src/client/common/platform/fs-paths.ts

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ export class FileSystemPaths {
6969
}
7070
}
7171

72+
// Where to fine executables.
73+
//
74+
// In particular this class provides all the tools needed to find
75+
// executables, including through an environment variable.
7276
export class Executables {
7377
constructor(
7478
public readonly delimiter: string,
@@ -91,10 +95,12 @@ export class Executables {
9195
}
9296
}
9397

98+
// The dependencies FileSystemPathUtils has on node's path module.
9499
interface IRawPaths {
95100
relative(relpath: string, rootpath: string): string;
96101
}
97102

103+
// A collection of high-level utilities related to filesystem paths.
98104
export class FileSystemPathUtils {
99105
constructor(
100106
public readonly home: string,
@@ -119,12 +125,16 @@ export class FileSystemPathUtils {
119125
);
120126
}
121127

128+
// Return true if the two paths are equivalent on the current
129+
// filesystem and false otherwise. On Windows this is significant.
130+
// On non-Windows the filenames must always be exactly the same.
122131
public arePathsSame(path1: string, path2: string): boolean {
123132
path1 = this.paths.normCase(path1);
124133
path2 = this.paths.normCase(path2);
125134
return path1 === path2;
126135
}
127136

137+
// Return the canonicalized absolute filename.
128138
public async getRealPath(filename: string): Promise<string> {
129139
try {
130140
return await fs.realpath(filename);
@@ -134,13 +144,14 @@ export class FileSystemPathUtils {
134144
}
135145
}
136146

137-
public getDisplayName(pathValue: string, cwd?: string): string {
138-
if (cwd && pathValue.startsWith(cwd)) {
139-
return `.${this.paths.sep}${this.raw.relative(cwd, pathValue)}`;
140-
} else if (pathValue.startsWith(this.home)) {
141-
return `~${this.paths.sep}${this.raw.relative(this.home, pathValue)}`;
147+
// Return the clean (displayable) form of the given filename.
148+
public getDisplayName(filename: string, cwd?: string): string {
149+
if (cwd && filename.startsWith(cwd)) {
150+
return `.${this.paths.sep}${this.raw.relative(cwd, filename)}`;
151+
} else if (filename.startsWith(this.home)) {
152+
return `~${this.paths.sep}${this.raw.relative(this.home, filename)}`;
142153
} else {
143-
return pathValue;
154+
return filename;
144155
}
145156
}
146157
}

0 commit comments

Comments
 (0)