panel: esc to close

fixes #2424
This commit is contained in:
isidor 2016-01-27 14:59:31 +01:00
parent eb9d146d85
commit 353f325bb3
2 changed files with 15 additions and 6 deletions

View file

@ -6,10 +6,11 @@
import 'vs/css!./media/panelPart';
import nls = require('vs/nls');
import {TPromise, Promise} from 'vs/base/common/winjs.base';
import {KeyMod, KeyCode} from 'vs/base/common/keyCodes';
import {KeyMod, KeyCode, CommonKeybindings} from 'vs/base/common/keyCodes';
import strings = require('vs/base/common/strings');
import {Action, IAction} from 'vs/base/common/actions';
import {Builder} from 'vs/base/browser/builder';
import dom = require('vs/base/browser/dom');
import {Registry} from 'vs/platform/platform';
import {Scope} from 'vs/workbench/browser/actionBarRegistry';
import {SyncActionDescriptor} from 'vs/platform/actions/common/actions';
@ -62,6 +63,17 @@ export class PanelPart extends CompositePart<Panel> implements IPanelService {
);
}
public create(parent: Builder): void {
super.create(parent);
dom.addStandardDisposableListener(this.getContainer().getHTMLElement(), 'keyup', (e: dom.IKeyboardEvent) => {
if (e.equals(CommonKeybindings.ESCAPE)) {
this.partService.setPanelHidden(true);
e.preventDefault();
}
});
}
public openPanel(id: string, focus?: boolean): TPromise<Panel> {
if (this.blockOpeningPanel) {
return TPromise.as(null); // Workaround against a potential race condition

View file

@ -19,7 +19,6 @@ import debugactions = require('vs/workbench/parts/debug/electron-browser/debugAc
import replhistory = require('vs/workbench/parts/debug/common/replHistory');
import { Panel } from 'vs/workbench/browser/panel';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IPartService } from 'vs/workbench/services/part/common/partService';
import { IContextViewService, IContextMenuService } from 'vs/platform/contextview/browser/contextView';
import { IInstantiationService, INullService } from 'vs/platform/instantiation/common/instantiation';
import { IWorkspaceContextService } from 'vs/workbench/services/workspace/common/contextService';
@ -59,8 +58,7 @@ export class Repl extends Panel {
@ITelemetryService telemetryService: ITelemetryService,
@IInstantiationService private instantiationService: IInstantiationService,
@IContextViewService private contextViewService: IContextViewService,
@IStorageService private storageService: IStorageService,
@IPartService private partService: IPartService
@IStorageService private storageService: IStorageService
) {
super(debug.REPL_ID, telemetryService);
@ -108,6 +106,7 @@ export class Repl extends Panel {
this.debugService.addReplExpression(trimmedValue);
Repl.HISTORY.evaluated(trimmedValue);
this.replInput.value = '';
e.preventDefault();
} else if (e.equals(CommonKeybindings.UP_ARROW) || e.equals(CommonKeybindings.DOWN_ARROW)) {
const historyInput = e.equals(CommonKeybindings.UP_ARROW) ? Repl.HISTORY.previous() : Repl.HISTORY.next();
if (historyInput) {
@ -116,8 +115,6 @@ export class Repl extends Panel {
// always leave cursor at the end.
e.preventDefault();
}
} else if (e.equals(CommonKeybindings.ESCAPE)) {
this.partService.setPanelHidden(true);
}
});