MCPcopy Create free account
hub / github.com/Acode-Foundation/Acode / toCodeMirrorKey

Function toCodeMirrorKey

src/cm/commandRegistry.js:1462–1501  ·  view source on GitHub ↗
(combo)

Source from the content-addressed store, hash-verified

1460}
1461
1462function toCodeMirrorKey(combo) {
1463 if (!combo) return null;
1464 const parts = combo.endsWith("-")
1465 ? [...combo.slice(0, -1).split("-").filter(Boolean), "-"]
1466 : combo
1467 .split("-")
1468 .map((part) => part.trim())
1469 .filter(Boolean);
1470 const modifiers = [];
1471 let key = null;
1472
1473 parts.forEach((part, index) => {
1474 const lower = part.toLowerCase();
1475 if (MODIFIER_MAP[lower]) {
1476 const mod = MODIFIER_MAP[lower];
1477 if (!modifiers.includes(mod)) modifiers.push(mod);
1478 return;
1479 }
1480
1481 if (ARROW_KEY_MAP[lower]) {
1482 key = ARROW_KEY_MAP[lower];
1483 return;
1484 }
1485
1486 if (SPECIAL_KEY_MAP[lower]) {
1487 key = SPECIAL_KEY_MAP[lower];
1488 return;
1489 }
1490
1491 if (part.length === 1 && /[a-z]/i.test(part)) {
1492 key = part.length === 1 ? part.toLowerCase() : part;
1493 return;
1494 }
1495
1496 key = part;
1497 });
1498
1499 if (!key) return modifiers.join("-") || null;
1500 return modifiers.length ? `${modifiers.join("-")}-${key}` : key;
1501}
1502
1503function rebuildKeymap() {
1504 const bindings = [];

Callers 1

rebuildKeymapFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected