MCPcopy
hub / github.com/paperwm/PaperWM / _updateCollisions

Method _updateCollisions

prefsKeybinding.js:572–607  ·  view source on GitHub ↗
(position, removed, added)

Source from the content-addressed store, hash-verified

570 }
571
572 _updateCollisions(position, removed, added) {
573 let map = new Map();
574 for (const binding of this._model) {
575 for (const combo of binding.combos) {
576 if (combo.disabled)
577 continue;
578 map.set(combo.keystr, (map.get(combo.keystr) || new Set()).add(binding.action));
579 }
580 }
581 let changed = new Set();
582 for (const [keystr, actions] of map.entries()) {
583 if (actions.size > 1) {
584 if (!this.collisions.has(keystr)) {
585 for (const action of actions) {
586 changed.add(action);
587 }
588 } else {
589 let old = this.collisions.get(keystr);
590 for (const action of symmetricDifference(old, actions)) {
591 changed.add(action);
592 }
593 }
594 this.collisions.set(keystr, actions);
595 } else {
596 for (const action of actions) {
597 changed.add(action);
598 }
599 this.collisions.delete(keystr);
600 }
601 }
602 if (changed.size > 0) {
603 for (const action of changed) {
604 this.emit(`collisions-changed::${action}`);
605 }
606 }
607 }
608});
609
610const ComboRow = GObject.registerClass({

Callers 2

_initMethod · 0.95
collisionsMethod · 0.95

Calls 2

symmetricDifferenceFunction · 0.85
addMethod · 0.80

Tested by

no test coverage detected