Skip to content

Commit

Permalink
Fix gen_wrapper.js was dropping some keybindings unexpectedly #10
Browse files Browse the repository at this point in the history
  • Loading branch information
tshino committed Nov 26, 2021
1 parent 56d0acf commit 9124016
Show file tree
Hide file tree
Showing 3 changed files with 337 additions and 144 deletions.
21 changes: 21 additions & 0 deletions generator/gen_wrapper_util.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ function makeCombinedKeybindingsForKeyPart1(contextList, unified, nonUnified) {
const [ nonUnifiedMac, pos ] = u.macKeybinding;
const nu = nonUnifiedMac[nonUnifiedMac.length - 1];
if (pos >= nu.length || nu[pos].done) {
combined.push(u.keybinding);
continue;
}
// flush keybindings that must be written before the unified keybinding.
Expand Down Expand Up @@ -311,6 +312,7 @@ function combineBaseKeybingings(baseKeybindings) {
if (!util.isDeepStrictEqual(u.contexts, otherThanMac)) {
continue;
}
let found = false;
for (const lookup of commandLookup.get(u.keybinding.command)) {
if (lookup.context !== 'isMac') {
continue;
Expand All @@ -321,12 +323,31 @@ function combineBaseKeybingings(baseKeybindings) {
const i = nonUnifiedMac.length - 1;
for (let k = 0; k < nonUnifiedMac[i].length; k++) {
const keybinding = nonUnifiedMac[i][k];
if (keybinding.matched) {
continue;
}
if (util.isDeepStrictEqual(target, keybinding)) {
// found candidate!
u.macKey = lookup.key;
u.macKeybinding = [ nonUnifiedMac, k ];
keybinding.matched = true;
found = true;
break;
}
}
if (found) {
break;
}
}
}
}
// clean-up
for (const key of keyDict.keys()) {
const unified = unifiedKeybindings.get(key) || [];
for (const u of unified) {
if (u.makKey) {
const [ nonUnifiedMac, k ] = u.macKeybinding[0];
delete nonUnifiedMac[nonUnifiedMac.length - 1][k].matched;
}
}
}
Expand Down
Loading

0 comments on commit 9124016

Please sign in to comment.