Skip to content

Commit

Permalink
Fix logic for 'containsKeybinding'
Browse files Browse the repository at this point in the history
Refactored `containsKeybinding` to return `true` when a collision is encountered, opposed to `false`

Signed-off-by: Vincent Fugnitto <vincent.fugnitto@ericsson.com>
  • Loading branch information
vince-fugnitto committed Sep 25, 2018
1 parent 23ee961 commit 09095b0
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/core/src/browser/keybinding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ export class KeybindingRegistry {

protected doRegisterKeybinding(binding: Keybinding, scope: KeybindingScope = KeybindingScope.DEFAULT) {
try {
if (!this.containsKeybinding(this.keymaps[scope], binding)) {
if (this.containsKeybinding(this.keymaps[scope], binding)) {
throw new Error(`"${binding.keybinding}" is in collision with something else [scope:${scope}]`);
}
this.keymaps[scope].push(binding);
Expand All @@ -197,21 +197,21 @@ export class KeybindingRegistry {
this.logger.warn('Collided keybinding is ignored; ',
Keybinding.stringify(binding), ' collided with ',
collisions.full.map(b => Keybinding.stringify(b)).join(', '));
return false;
return true;
}
if (collisions.partial.length > 0) {
this.logger.warn('Shadowing keybinding is ignored; ',
Keybinding.stringify(binding), ' shadows ',
collisions.partial.map(b => Keybinding.stringify(b)).join(', '));
return false;
return true;
}
if (collisions.shadow.length > 0) {
this.logger.warn('Shadowed keybinding is ignored; ',
Keybinding.stringify(binding), ' would be shadowed by ',
collisions.shadow.map(b => Keybinding.stringify(b)).join(', '));
return false;
return true;
}
return true;
return false;
}

/**
Expand Down

0 comments on commit 09095b0

Please sign in to comment.