register global action to close quick open
This commit is contained in:
parent
5e5deb9a8a
commit
44fa4c3090
|
@ -517,6 +517,10 @@ export class TestQuickOpenService implements QuickOpenService.IQuickOpenService
|
|||
return TPromise.as(null);
|
||||
}
|
||||
|
||||
close(): void {
|
||||
|
||||
}
|
||||
|
||||
show(prefix?: string, options?: any): Promise {
|
||||
if (this.callback) {
|
||||
this.callback(prefix);
|
||||
|
|
|
@ -30,7 +30,7 @@ import {Scope, IActionBarRegistry, Extensions as ActionBarExtensions, ActionBarC
|
|||
import {SyncActionDescriptor} from 'vs/platform/actions/common/actions';
|
||||
import {SyncDescriptor} from 'vs/platform/instantiation/common/descriptors';
|
||||
import {KeyMod, KeyCode} from 'vs/base/common/keyCodes';
|
||||
import {CloseEditorsInGroupAction, CloseEditorsInOtherGroupsAction, CloseAllEditorsAction, MoveGroupLeftAction, MoveGroupRightAction, SplitEditorAction, KeepEditorAction, CloseOtherEditorsInGroupAction, OpenToSideAction,
|
||||
import {CloseEditorsInGroupAction, CloseEditorsInOtherGroupsAction, CloseAllEditorsAction, MoveGroupLeftAction, MoveGroupRightAction, SplitEditorAction, KeepEditorAction, CloseOtherEditorsInGroupAction, OpenToSideAction, QuickOpenCloseAction,
|
||||
NavigateBetweenGroupsAction, FocusFirstGroupAction, FocusSecondGroupAction, FocusThirdGroupAction, EvenGroupWidthsAction, MaximizeGroupAction, MinimizeOtherGroupsAction, FocusPreviousGroup, FocusNextGroup, ShowEditorsInLeftGroupAction,
|
||||
toEditorQuickOpenEntry, CloseLeftEditorsInGroupAction, CloseRightEditorsInGroupAction, OpenNextEditor, OpenPreviousEditor, NavigateBackwardsAction, NavigateForwardAction, ReopenClosedEditorAction, OpenPreviousRecentlyUsedEditorInGroupAction, NAVIGATE_IN_LEFT_GROUP_PREFIX,
|
||||
GlobalQuickOpenAction, OpenPreviousEditorFromHistoryAction, QuickOpenNavigateNextAction, QuickOpenNavigatePreviousAction, ShowAllEditorsAction, NAVIGATE_ALL_EDITORS_GROUP_PREFIX, ClearEditorHistoryAction, ShowEditorsInCenterGroupAction, MoveEditorRightInGroupAction,
|
||||
|
@ -258,6 +258,7 @@ registry.registerWorkbenchAction(new SyncActionDescriptor(ClearEditorHistoryActi
|
|||
registry.registerWorkbenchAction(new SyncActionDescriptor(RemoveFromEditorHistoryAction, RemoveFromEditorHistoryAction.ID, RemoveFromEditorHistoryAction.LABEL), 'Remove From Editor History');
|
||||
registry.registerWorkbenchAction(new SyncActionDescriptor(QuickOpenNavigateNextAction, QuickOpenNavigateNextAction.ID, QuickOpenNavigateNextAction.LABEL, navigateKeybinding(false), ContextKeyExpr.has('inQuickOpen')), 'Navigate Next in Quick Open');
|
||||
registry.registerWorkbenchAction(new SyncActionDescriptor(QuickOpenNavigatePreviousAction, QuickOpenNavigatePreviousAction.ID, QuickOpenNavigatePreviousAction.LABEL, navigateKeybinding(true), ContextKeyExpr.has('inQuickOpen'), KeybindingsRegistry.WEIGHT.workbenchContrib(50)), 'Navigate Previous in Quick Open');
|
||||
registry.registerWorkbenchAction(new SyncActionDescriptor(QuickOpenCloseAction, QuickOpenCloseAction.ID, QuickOpenCloseAction.LABEL, { primary: KeyCode.Escape, secondary: [KeyMod.Shift | KeyCode.Escape] }, ContextKeyExpr.has('inQuickOpen')), 'Close Quick Open');
|
||||
|
||||
// Keybindings to focus a specific index in the tab folder if tabs are enabled
|
||||
for (let i = 0; i < 9; i++) {
|
||||
|
|
|
@ -1243,6 +1243,26 @@ export class QuickOpenNavigatePreviousAction extends BaseQuickOpenNavigateAction
|
|||
}
|
||||
}
|
||||
|
||||
export class QuickOpenCloseAction extends Action {
|
||||
|
||||
public static ID = 'workbench.action.closeQuickOpen';
|
||||
public static LABEL = nls.localize('closeQuickOpen', "Close Quick Open");
|
||||
|
||||
constructor(
|
||||
id: string,
|
||||
label: string,
|
||||
@IQuickOpenService private quickOpenService: IQuickOpenService
|
||||
) {
|
||||
super(id, label);
|
||||
}
|
||||
|
||||
public run(event?: any): TPromise<any> {
|
||||
this.quickOpenService.close();
|
||||
|
||||
return TPromise.as(true);
|
||||
}
|
||||
}
|
||||
|
||||
interface IEditorPickOpenEntry extends IPickOpenEntry {
|
||||
identifier: IEditorIdentifier;
|
||||
}
|
||||
|
|
|
@ -229,12 +229,16 @@ export class QuickOpenController extends WorkbenchComponent implements IQuickOpe
|
|||
onOk: () => { /* ignore, handle later */ },
|
||||
onCancel: () => { /* ignore, handle later */ },
|
||||
onType: (value: string) => { /* ignore, handle later */ },
|
||||
onShow: () => this.emitQuickOpenVisibilityChange(true),
|
||||
onShow: () => {
|
||||
this.inQuickOpenMode.set(true);
|
||||
this.emitQuickOpenVisibilityChange(true);
|
||||
},
|
||||
onHide: (reason) => {
|
||||
if (reason !== HideReason.FOCUS_LOST) {
|
||||
this.restoreFocus(); // focus back to editor unless user clicked somewhere else
|
||||
}
|
||||
this.emitQuickOpenVisibilityChange(false); // event
|
||||
this.inQuickOpenMode.reset();
|
||||
this.emitQuickOpenVisibilityChange(false);
|
||||
}
|
||||
}, {
|
||||
inputPlaceHolder: options.placeHolder || ''
|
||||
|
@ -373,13 +377,15 @@ export class QuickOpenController extends WorkbenchComponent implements IQuickOpe
|
|||
this.pickOpenWidget.refresh(model, value ? { autoFocusFirstEntry: true } : autoFocus);
|
||||
},
|
||||
onShow: () => {
|
||||
this.emitQuickOpenVisibilityChange(true); // event
|
||||
this.inQuickOpenMode.set(true);
|
||||
this.emitQuickOpenVisibilityChange(true);
|
||||
},
|
||||
onHide: (reason) => {
|
||||
if (reason !== HideReason.FOCUS_LOST) {
|
||||
this.restoreFocus(); // focus back to editor unless user clicked somewhere else
|
||||
}
|
||||
this.emitQuickOpenVisibilityChange(false); // event
|
||||
this.inQuickOpenMode.reset();
|
||||
this.emitQuickOpenVisibilityChange(false);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -409,6 +415,16 @@ export class QuickOpenController extends WorkbenchComponent implements IQuickOpe
|
|||
});
|
||||
}
|
||||
|
||||
public close(): void {
|
||||
if (this.quickOpenWidget) {
|
||||
this.quickOpenWidget.hide();
|
||||
}
|
||||
|
||||
if (this.pickOpenWidget) {
|
||||
this.pickOpenWidget.hide();
|
||||
}
|
||||
}
|
||||
|
||||
private emitQuickOpenVisibilityChange(isVisible: boolean): void {
|
||||
if (this.visibilityChangeTimeoutHandle) {
|
||||
window.clearTimeout(this.visibilityChangeTimeoutHandle);
|
||||
|
|
|
@ -117,6 +117,11 @@ export interface IQuickOpenService {
|
|||
*/
|
||||
input(options?: IInputOptions, token?: CancellationToken): TPromise<string>;
|
||||
|
||||
/**
|
||||
* Closes any opened quick open.
|
||||
*/
|
||||
close(): void;
|
||||
|
||||
/**
|
||||
* Allows to register on the event that quick open is showing
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue