mirror of
https://github.com/Microsoft/vscode
synced 2024-09-13 21:55:38 +00:00
title - better simulate mac behaviour when opening path from title
This commit is contained in:
parent
7403c72f4c
commit
fc5f80e1ba
|
@ -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<void> {
|
||||
|
|
Loading…
Reference in a new issue