@@ -59,15 +59,15 @@ export class KeybindingsSearchWidget extends SearchWidget {
59
59
@IKeybindingService keybindingService : IKeybindingService ,
60
60
) {
61
61
super ( parent , options , contextViewService , instantiationService , contextKeyService , keybindingService ) ;
62
+
62
63
this . _register ( toDisposable ( ( ) => this . stopRecordingKeys ( ) ) ) ;
64
+
63
65
this . _chords = null ;
64
66
this . _inputValue = '' ;
65
-
66
- this . _reset ( ) ;
67
67
}
68
68
69
69
override clear ( ) : void {
70
- this . _reset ( ) ;
70
+ this . _chords = null ;
71
71
super . clear ( ) ;
72
72
}
73
73
@@ -81,7 +81,7 @@ export class KeybindingsSearchWidget extends SearchWidget {
81
81
}
82
82
83
83
stopRecordingKeys ( ) : void {
84
- this . _reset ( ) ;
84
+ this . _chords = null ;
85
85
this . recordDisposables . clear ( ) ;
86
86
}
87
87
@@ -90,10 +90,6 @@ export class KeybindingsSearchWidget extends SearchWidget {
90
90
this . inputBox . value = this . _inputValue ;
91
91
}
92
92
93
- private _reset ( ) {
94
- this . _chords = null ;
95
- }
96
-
97
93
private _onKeyDown ( keyboardEvent : IKeyboardEvent ) : void {
98
94
keyboardEvent . preventDefault ( ) ;
99
95
keyboardEvent . stopPropagation ( ) ;
@@ -103,10 +99,6 @@ export class KeybindingsSearchWidget extends SearchWidget {
103
99
return ;
104
100
}
105
101
if ( keyboardEvent . equals ( KeyCode . Escape ) ) {
106
- if ( this . _chords !== null ) {
107
- this . clear ( ) ;
108
- }
109
-
110
102
this . _onEscape . fire ( ) ;
111
103
return ;
112
104
}
@@ -185,8 +177,8 @@ export class DefineKeybindingWidget extends Widget {
185
177
this . _keybindingInputWidget . startRecordingKeys ( ) ;
186
178
this . _register ( this . _keybindingInputWidget . onKeybinding ( keybinding => this . onKeybinding ( keybinding ) ) ) ;
187
179
this . _register ( this . _keybindingInputWidget . onEnter ( ( ) => this . hide ( ) ) ) ;
188
- this . _register ( this . _keybindingInputWidget . onEscape ( ( ) => this . onEscape ( ) ) ) ;
189
- this . _register ( this . _keybindingInputWidget . onBlur ( ( ) => this . onBlur ( ) ) ) ;
180
+ this . _register ( this . _keybindingInputWidget . onEscape ( ( ) => this . clearOrHide ( ) ) ) ;
181
+ this . _register ( this . _keybindingInputWidget . onBlur ( ( ) => this . onCancel ( ) ) ) ;
190
182
191
183
this . _outputNode = dom . append ( this . _domNode . domNode , dom . $ ( '.output' ) ) ;
192
184
this . _showExistingKeybindingsNode = dom . append ( this . _domNode . domNode , dom . $ ( '.existing' ) ) ;
@@ -251,19 +243,15 @@ export class DefineKeybindingWidget extends Widget {
251
243
dom . clearNode ( this . _outputNode ) ;
252
244
dom . clearNode ( this . _showExistingKeybindingsNode ) ;
253
245
254
-
255
-
256
246
const firstLabel = new KeybindingLabel ( this . _outputNode , OS , defaultKeybindingLabelStyles ) ;
257
247
firstLabel . set ( withNullAsUndefined ( this . _chords ?. [ 0 ] ) ) ;
258
248
259
-
260
249
if ( this . _chords ) {
261
250
for ( let i = 1 ; i < this . _chords . length ; i ++ ) {
262
251
this . _outputNode . appendChild ( document . createTextNode ( nls . localize ( 'defineKeybinding.chordsTo' , "chord to" ) ) ) ;
263
252
const chordLabel = new KeybindingLabel ( this . _outputNode , OS , defaultKeybindingLabelStyles ) ;
264
253
chordLabel . set ( this . _chords [ i ] ) ;
265
254
}
266
-
267
255
}
268
256
269
257
const label = this . getUserSettingsLabel ( ) ;
@@ -280,19 +268,20 @@ export class DefineKeybindingWidget extends Widget {
280
268
return label ;
281
269
}
282
270
283
- private onBlur ( ) : void {
271
+ private onCancel ( ) : void {
284
272
this . _chords = null ;
285
273
this . hide ( ) ;
286
274
}
287
275
288
- private onEscape ( ) : void {
289
- if ( this . _chords !== null ) {
276
+ private clearOrHide ( ) : void {
277
+ if ( this . _chords === null ) {
278
+ this . hide ( ) ;
279
+ } else {
290
280
this . _chords = null ;
281
+ this . _keybindingInputWidget . clear ( ) ;
291
282
dom . clearNode ( this . _outputNode ) ;
292
283
dom . clearNode ( this . _showExistingKeybindingsNode ) ;
293
- return ;
294
284
}
295
- this . hide ( ) ;
296
285
}
297
286
298
287
private hide ( ) : void {
0 commit comments