@@ -60,7 +60,7 @@ export interface ScopedKeybinding extends common.Keybinding {
60
60
61
61
export const KeybindingContribution = Symbol ( 'KeybindingContribution' ) ;
62
62
/**
63
- * Representation of a keybinding contribution.
63
+ * Allows extensions to contribute { @link common.Keybinding}s
64
64
*/
65
65
export interface KeybindingContribution {
66
66
/**
@@ -168,36 +168,36 @@ export class KeybindingRegistry {
168
168
*
169
169
* Keybindings registered later have higher priority during evaluation.
170
170
*
171
- * @param binding
171
+ * @param binding the keybinding to be registered
172
172
*/
173
173
registerKeybinding ( binding : common . Keybinding ) : Disposable {
174
174
return this . doRegisterKeybinding ( binding ) ;
175
175
}
176
176
177
177
/**
178
- * Register default keybindings to the registry
178
+ * Register multiple default keybindings to the registry
179
179
*
180
- * @param bindings
180
+ * @param bindings An array of keybinding to be registered
181
181
*/
182
182
registerKeybindings ( ...bindings : common . Keybinding [ ] ) : Disposable {
183
183
return this . doRegisterKeybindings ( bindings , KeybindingScope . DEFAULT ) ;
184
184
}
185
185
186
186
/**
187
- * Unregister keybindings from the registry using the key of the given keybinding
187
+ * Unregister all keybindings from the registry that are bound to the key of the given keybinding
188
188
*
189
- * @param binding a Keybinding specifying the key to be unregistered
189
+ * @param binding a keybinding specifying the key to be unregistered
190
190
*/
191
191
unregisterKeybinding ( binding : common . Keybinding ) : void ;
192
192
/**
193
- * Unregister keybindings with the given key from the registry
193
+ * Unregister all keybindings with the given key from the registry
194
194
*
195
195
* @param key a key to be unregistered
196
196
*/
197
197
unregisterKeybinding ( key : string ) : void ;
198
198
/**
199
199
* Unregister all existing keybindings for the given command
200
- * @param command the command to unregister keybindings for
200
+ * @param command the command to unregister all keybindings for
201
201
*/
202
202
unregisterKeybinding ( command : Command ) : void ;
203
203
@@ -266,6 +266,12 @@ export class KeybindingRegistry {
266
266
}
267
267
}
268
268
269
+ /**
270
+ * Checks whether a colliding {@link common.Keybinding} exists in a specific scope.
271
+ * @param binding the keybinding to check
272
+ * @param scope the keybinding scope to check
273
+ * @returns true if there is a colliding keybinding
274
+ */
269
275
containsKeybindingInScope ( binding : common . Keybinding , scope = KeybindingScope . USER ) : boolean {
270
276
const bindingKeySequence = this . resolveKeybinding ( binding ) ;
271
277
const collisions = this . getKeySequenceCollisions ( this . keymaps [ scope ] , bindingKeySequence )
@@ -283,22 +289,31 @@ export class KeybindingRegistry {
283
289
}
284
290
285
291
/**
286
- * Return a user visible representation of a keybinding.
292
+ * Get a user visible representation of a {@link common.Keybinding}.
293
+ * @returns an array of strings representing all elements of the {@link KeySequence} defined by the {@link common.Keybinding}
294
+ * @param keybinding the keybinding
295
+ * @param separator the separator to be used to stringify {@link KeyCode}s that are part of the {@link KeySequence}
287
296
*/
288
297
acceleratorFor ( keybinding : common . Keybinding , separator : string = ' ' ) : string [ ] {
289
298
const bindingKeySequence = this . resolveKeybinding ( keybinding ) ;
290
299
return this . acceleratorForSequence ( bindingKeySequence , separator ) ;
291
300
}
292
301
293
302
/**
294
- * Return a user visible representation of a key sequence.
303
+ * Get a user visible representation of a {@link KeySequence}.
304
+ * @returns an array of strings representing all elements of the {@link KeySequence}
305
+ * @param keySequence the keysequence
306
+ * @param separator the separator to be used to stringify {@link KeyCode}s that are part of the {@link KeySequence}
295
307
*/
296
308
acceleratorForSequence ( keySequence : KeySequence , separator : string = ' ' ) : string [ ] {
297
309
return keySequence . map ( keyCode => this . acceleratorForKeyCode ( keyCode , separator ) ) ;
298
310
}
299
311
300
312
/**
301
- * Return a user visible representation of a key code (a key with modifiers).
313
+ * Get a user visible representation of a key code (a key with modifiers).
314
+ * @returns a string representing the {@link KeyCode}
315
+ * @param keyCode the keycode
316
+ * @param separator the separator used to separate keys (key and modifiers) in the returning string
302
317
*/
303
318
acceleratorForKeyCode ( keyCode : KeyCode , separator : string = ' ' ) : string {
304
319
const keyCodeResult = [ ] ;
@@ -383,9 +398,10 @@ export class KeybindingRegistry {
383
398
}
384
399
385
400
/**
386
- * Get the keybindings associated to commandId.
401
+ * Get all keybindings associated to a commandId.
387
402
*
388
403
* @param commandId The ID of the command for which we are looking for keybindings.
404
+ * @returns an array of {@link ScopedKeybinding}
389
405
*/
390
406
getKeybindingsForCommand ( commandId : string ) : ScopedKeybinding [ ] {
391
407
const result : ScopedKeybinding [ ] = [ ] ;
@@ -577,6 +593,11 @@ export class KeybindingRegistry {
577
593
return commandId === KeybindingRegistry . PASSTHROUGH_PSEUDO_COMMAND ;
578
594
}
579
595
596
+ /**
597
+ * Sets a new keymap replacing all existing {@link common.Keybinding}s in the given scope.
598
+ * @param scope the keybinding scope
599
+ * @param bindings an array containing the new {@link common.Keybinding}s
600
+ */
580
601
setKeymap ( scope : KeybindingScope , bindings : common . Keybinding [ ] ) : void {
581
602
this . resetKeybindingsForScope ( scope ) ;
582
603
this . toResetKeymap . set ( scope , this . doRegisterKeybindings ( bindings , scope ) ) ;
@@ -605,6 +626,11 @@ export class KeybindingRegistry {
605
626
}
606
627
}
607
628
629
+ /**
630
+ * Get all {@link common.Keybinding}s for a {@link KeybindingScope}.
631
+ * @returns an array of {@link common.ScopedKeybinding}
632
+ * @param scope the keybinding scope to retrieve the {@link common.Keybinding}s for.
633
+ */
608
634
getKeybindingsByScope ( scope : KeybindingScope ) : ScopedKeybinding [ ] {
609
635
return this . keymaps [ scope ] ;
610
636
}
0 commit comments