diff --git a/src/vs/workbench/browser/parts/titlebar/titlebarPart.ts b/src/vs/workbench/browser/parts/titlebar/titlebarPart.ts index b69e64f80109876c702d117823c9d9df6d353a87..94d7152dd84b4b8572574c9d6c4593c4b717ad1f 100644 --- a/src/vs/workbench/browser/parts/titlebar/titlebarPart.ts +++ b/src/vs/workbench/browser/parts/titlebar/titlebarPart.ts @@ -99,8 +99,21 @@ export class TitlebarPart extends Part implements ITitleService { if (this.representedFileName) { const segments = this.representedFileName.split(paths.sep); for (let i = segments.length; i > 0; i--) { - const path = segments.slice(0, i).join(paths.sep); - actions.push(new ShowItemInFolderAction(path, this.windowsService)); + const isFile = (i === segments.length); + + let pathOffset = i; + if (!isFile) { + pathOffset++; // for segments which are not the file name we want to open the folder + } + + const path = segments.slice(0, pathOffset).join(paths.sep); + + let label = paths.basename(path); + if (!isFile) { + label = paths.basename(paths.dirname(path)); + } + + actions.push(new ShowItemInFolderAction(path, label || paths.sep, this.windowsService)); } } @@ -143,8 +156,8 @@ export class TitlebarPart extends Part implements ITitleService { class ShowItemInFolderAction extends Action { - constructor(private path: string, private windowsService: IWindowsService) { - super('showItemInFolder.action.id', paths.basename(path) || paths.sep); + constructor(private path: string, label: string, private windowsService: IWindowsService) { + super('showItemInFolder.action.id', label); } public run(): TPromise {