Skip to content

Commit

Permalink
core: handle dismissing quick-open menus without focus (#12446)
Browse files Browse the repository at this point in the history
The commit adds handling to properly dismiss the quick-open menu through keybindings when it does not have explicit focus.

Signed-off-by: FernandoAscencio <[email protected]>
Co-authored-by: vince-fugnitto <[email protected]>
  • Loading branch information
FernandoAscencio and vince-fugnitto authored May 15, 2023
1 parent 3eb7137 commit 15e7cd9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { injectable, inject, optional } from 'inversify';
import { CommandRegistry, CommandContribution, MenuContribution, MenuModelRegistry, nls } from '../../common';
import { KeybindingRegistry, KeybindingContribution } from '../keybinding';
import { CommonMenus } from '../common-frontend-contribution';
import { CLEAR_COMMAND_HISTORY, quickCommand, QuickCommandService } from './quick-command-service';
import { CLOSE_QUICK_OPEN, CLEAR_COMMAND_HISTORY, quickCommand, QuickCommandService } from './quick-command-service';
import { QuickInputService } from './quick-input-service';
import { ConfirmDialog, Dialog } from '../dialogs';

Expand Down Expand Up @@ -49,6 +49,9 @@ export class QuickCommandFrontendContribution implements CommandContribution, Ke
}
}
});
commands.registerCommand(CLOSE_QUICK_OPEN, {
execute: () => this.quickInputService?.hide()
});
}

registerMenus(menus: MenuModelRegistry): void {
Expand All @@ -67,5 +70,15 @@ export class QuickCommandFrontendContribution implements CommandContribution, Ke
command: quickCommand.id,
keybinding: 'ctrlcmd+shift+p'
});
keybindings.registerKeybinding({
command: CLOSE_QUICK_OPEN.id,
keybinding: 'esc',
when: 'inQuickOpen'
});
keybindings.registerKeybinding({
command: CLOSE_QUICK_OPEN.id,
keybinding: 'shift+esc',
when: 'inQuickOpen'
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ export const CLEAR_COMMAND_HISTORY = Command.toDefaultLocalizedCommand({
label: 'Clear Command History'
});

export const CLOSE_QUICK_OPEN: Command = {
id: 'workbench.action.closeQuickOpen'
};

@injectable()
export class QuickCommandService implements QuickAccessContribution, QuickAccessProvider {
static PREFIX = '>';
Expand Down

0 comments on commit 15e7cd9

Please sign in to comment.