Skip to content

Commit 8e705be

Browse files
committed
define-keybinding widget: escape clears if non-empty, otherwise hides the widget
1 parent df6ef7f commit 8e705be

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/vs/workbench/contrib/preferences/browser/keybindingWidgets.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ export class DefineKeybindingWidget extends Widget {
177177
this._keybindingInputWidget.startRecordingKeys();
178178
this._register(this._keybindingInputWidget.onKeybinding(keybinding => this.onKeybinding(keybinding)));
179179
this._register(this._keybindingInputWidget.onEnter(() => this.hide()));
180-
this._register(this._keybindingInputWidget.onEscape(() => this.onCancel()));
180+
this._register(this._keybindingInputWidget.onEscape(() => this.clearOrHide()));
181181
this._register(this._keybindingInputWidget.onBlur(() => this.onCancel()));
182182

183183
this._outputNode = dom.append(this._domNode.domNode, dom.$('.output'));
@@ -273,6 +273,17 @@ export class DefineKeybindingWidget extends Widget {
273273
this.hide();
274274
}
275275

276+
private clearOrHide(): void {
277+
if (this._chords === null) {
278+
this.hide();
279+
} else {
280+
this._chords = null;
281+
this._keybindingInputWidget.clear();
282+
dom.clearNode(this._outputNode);
283+
dom.clearNode(this._showExistingKeybindingsNode);
284+
}
285+
}
286+
276287
private hide(): void {
277288
this._domNode.setDisplay('none');
278289
this._isVisible = false;

0 commit comments

Comments
 (0)