quick pick - do not pick second editor if group is empty

This commit is contained in:
Benjamin Pasero 2020-05-18 09:30:43 +02:00
parent b516873406
commit 06cc01337c
2 changed files with 11 additions and 3 deletions

View file

@ -151,7 +151,7 @@ CommandsRegistry.registerCommand({
}
});
CommandsRegistry.registerCommand('workbench.action.quickOpenPreviousEditor', async function (accessor: ServicesAccessor, prefix: string | null = null) {
CommandsRegistry.registerCommand('workbench.action.quickOpenPreviousEditor', async accessor => {
const quickInputService = accessor.get(IQuickInputService);
quickInputService.quickAccess.show('', { itemActivation: ItemActivation.SECOND });

View file

@ -1339,7 +1339,8 @@ export class QuickAccessPreviousEditorFromHistoryAction extends Action {
id: string,
label: string,
@IQuickInputService private readonly quickInputService: IQuickInputService,
@IKeybindingService private readonly keybindingService: IKeybindingService
@IKeybindingService private readonly keybindingService: IKeybindingService,
@IEditorGroupsService private readonly editorGroupService: IEditorGroupsService
) {
super(id, label);
}
@ -1347,7 +1348,14 @@ export class QuickAccessPreviousEditorFromHistoryAction extends Action {
async run(): Promise<void> {
const keybindings = this.keybindingService.lookupKeybindings(this.id);
this.quickInputService.quickAccess.show('', { quickNavigateConfiguration: { keybindings } });
// Enforce to activate the first item in quick access if
// the currently active editor group has n editor opened
let itemActivation: ItemActivation | undefined = undefined;
if (this.editorGroupService.activeGroup.count === 0) {
itemActivation = ItemActivation.FIRST;
}
this.quickInputService.quickAccess.show('', { quickNavigateConfiguration: { keybindings }, itemActivation });
}
}