Skip to content

Commit b561fea

Browse files
authored
1 parent 9784f87 commit b561fea

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/vs/workbench/services/editor/common/customEditorLabelService.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
import { Emitter, Event } from 'vs/base/common/event';
77
import { ParsedPattern, parse as parseGlob } from 'vs/base/common/glob';
88
import { Disposable } from 'vs/base/common/lifecycle';
9-
import { isAbsolute, parse as parsePath, ParsedPath } from 'vs/base/common/path';
10-
import { dirname, relativePath as getRelativePath } from 'vs/base/common/resources';
9+
import { isAbsolute, parse as parsePath, ParsedPath, dirname } from 'vs/base/common/path';
10+
import { dirname as resourceDirname, relativePath as getRelativePath } from 'vs/base/common/resources';
1111
import { URI } from 'vs/base/common/uri';
1212
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
1313
import { InstantiationType, registerSingleton } from 'vs/platform/instantiation/common/extensions';
@@ -139,7 +139,7 @@ export class CustomEditorLabelService extends Disposable implements ICustomEdito
139139
for (const pattern of this.patterns) {
140140
let relevantPath: string;
141141
if (root && !pattern.isAbsolutePath) {
142-
relevantPath = relativePath ?? getRelativePath(dirname(root.uri), resource) ?? resource.path;
142+
relevantPath = relativePath ?? getRelativePath(resourceDirname(root.uri), resource) ?? resource.path;
143143
} else {
144144
relevantPath = resource.path;
145145
}
@@ -164,7 +164,7 @@ export class CustomEditorLabelService extends Disposable implements ICustomEdito
164164
return parsedPath.ext.slice(1);
165165
default: { // dirname and dirname(arg)
166166
const n = variable === 'dirname' ? 0 : parseInt(arg);
167-
const nthDir = this.getNthDirname(relevantPath, parsedPath.name, n);
167+
const nthDir = this.getNthDirname(dirname(relevantPath), n);
168168
if (nthDir) {
169169
return nthDir;
170170
}
@@ -175,7 +175,7 @@ export class CustomEditorLabelService extends Disposable implements ICustomEdito
175175
});
176176
}
177177

178-
private getNthDirname(path: string, filename: string, n: number): string | undefined {
178+
private getNthDirname(path: string, n: number): string | undefined {
179179
// grand-parent/parent/filename.ext1.ext2 -> [grand-parent, parent]
180180
path = path.startsWith('/') ? path.slice(1) : path;
181181
const pathFragments = path.split('/');
@@ -189,7 +189,7 @@ export class CustomEditorLabelService extends Disposable implements ICustomEdito
189189
nth = length - 1 - n - 1; // -1 for the filename, -1 for 0-based index
190190
}
191191

192-
const nthDir = nth === pathFragments.length - 1 ? filename : pathFragments[nth];
192+
const nthDir = pathFragments[nth];
193193
if (nthDir === undefined || nthDir === '') {
194194
return undefined;
195195
}

0 commit comments

Comments
 (0)