quick open recent: handle case of untitled workspace better

This commit is contained in:
Benjamin Pasero 2017-08-21 11:45:32 +02:00
parent 9486562add
commit 658c68ce00

View file

@ -753,11 +753,23 @@ export abstract class BaseOpenRecentAction extends Action {
const workspacePicks: IFilePickOpenEntry[] = recentWorkspaces.map((workspace, index) => toPick(workspace, index === 0 ? { label: nls.localize('workspaces', "workspaces") } : void 0, isSingleFolderWorkspaceIdentifier(workspace) ? FileKind.FOLDER : FileKind.ROOT_FOLDER, this.environmentService, !this.isQuickNavigate() ? this.removeAction : void 0));
const filePicks: IFilePickOpenEntry[] = recentFiles.map((p, index) => toPick(p, index === 0 ? { label: nls.localize('files', "files"), border: true } : void 0, FileKind.FILE, this.environmentService, !this.isQuickNavigate() ? this.removeAction : void 0));
const hasWorkspace = this.contextService.hasWorkspace();
let isCurrentWorkspaceInList: boolean;
if (!this.contextService.hasWorkspace()) {
isCurrentWorkspaceInList = false; // we never show empty workspaces
} else if (this.contextService.hasFolderWorkspace()) {
isCurrentWorkspaceInList = true; // we always show folder workspaces
} else {
const firstWorkspace = recentWorkspaces[0];
if (firstWorkspace && !isSingleFolderWorkspaceIdentifier(firstWorkspace)) {
isCurrentWorkspaceInList = firstWorkspace.id === this.contextService.getWorkspace().id;
} else {
isCurrentWorkspaceInList = false; // this is an untitled workspace thereby
}
}
this.quickOpenService.pick([...workspacePicks, ...filePicks], {
contextKey: inRecentFilesPickerContextKey,
autoFocus: { autoFocusFirstEntry: !hasWorkspace, autoFocusSecondEntry: hasWorkspace },
autoFocus: { autoFocusFirstEntry: !isCurrentWorkspaceInList, autoFocusSecondEntry: isCurrentWorkspaceInList },
placeHolder: isMacintosh ? nls.localize('openRecentPlaceHolderMac', "Select to open (hold Cmd-key to open in new window)") : nls.localize('openRecentPlaceHolder', "Select to open (hold Ctrl-key to open in new window)"),
matchOnDescription: true,
quickNavigateConfiguration: this.isQuickNavigate() ? { keybindings: this.keybindingService.lookupKeybindings(this.id) } : void 0