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

Function rebuildKeymap

src/cm/commandRegistry.js:1503–1529  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1501}
1502
1503function rebuildKeymap() {
1504 const bindings = [];
1505 cachedResolvedKeyBindings = buildResolvedKeyBindingsSnapshot();
1506 commandMap.forEach((command, name) => {
1507 const bindingInfo = resolveBindingInfo(name);
1508 command.description =
1509 bindingInfo?.description || command.defaultDescription;
1510 const keySource =
1511 bindingInfo && Object.prototype.hasOwnProperty.call(bindingInfo, "key")
1512 ? bindingInfo.key
1513 : (command.defaultKey ?? null);
1514 command.key = keySource;
1515 const combos = parseKeyString(keySource);
1516 combos.forEach((combo) => {
1517 const cmKey = toCodeMirrorKey(combo);
1518 if (!cmKey) return;
1519 bindings.push({
1520 key: cmKey,
1521 run: (view) => executeCommand(name, view),
1522 preventDefault: true,
1523 });
1524 });
1525 });
1526 cachedKeymap = bindings;
1527 resolvedKeyBindingsVersion += 1;
1528 return bindings;
1529}
1530
1531function resolveCommand(name) {
1532 return commandMap.get(name) || null;

Callers 4

commandRegistry.jsFile · 0.85
setKeyBindingsFunction · 0.85
registerExternalCommandFunction · 0.85
removeExternalCommandFunction · 0.85

Calls 6

resolveBindingInfoFunction · 0.85
parseKeyStringFunction · 0.85
toCodeMirrorKeyFunction · 0.85
callMethod · 0.80
executeCommandFunction · 0.70

Tested by

no test coverage detected