Skip to content

Commit 78dcc8f

Browse files
authored
Merge pull request microsoft#211524 from microsoft/benibenj/dirnameFix
Fix wrong directory for Custom Editor Labels
2 parents b55887a + ed0b5c6 commit 78dcc8f

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,10 @@ 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(resourceDirname(root.uri), resource) ?? resource.path;
142+
if (!relativePath) {
143+
relativePath = getRelativePath(resourceDirname(root.uri), resource) ?? resource.path;
144+
}
145+
relevantPath = relativePath;
143146
} else {
144147
relevantPath = resource.path;
145148
}
@@ -186,7 +189,7 @@ export class CustomEditorLabelService extends Disposable implements ICustomEdito
186189
if (n < 0) {
187190
nth = Math.abs(n) - 1;
188191
} else {
189-
nth = length - 1 - n - 1; // -1 for the filename, -1 for 0-based index
192+
nth = length - n - 1;
190193
}
191194

192195
const nthDir = pathFragments[nth];

0 commit comments

Comments
 (0)