Skip to content

Commit

Permalink
Fix Alt+G on Windows/Linux (#943)
Browse files Browse the repository at this point in the history
fixes #921
  • Loading branch information
esimkowitz authored Oct 3, 2024
1 parent aec7d08 commit c34fa96
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions frontend/app/store/keymodel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ import * as jotai from "jotai";
const simpleControlShiftAtom = jotai.atom(false);
const globalKeyMap = new Map<string, (waveEvent: WaveKeyboardEvent) => boolean>();

function getFocusedBlockInActiveTab() {
const activeTabId = globalStore.get(atoms.activeTabId);
const layoutModel = getLayoutModelForTabById(activeTabId);
const focusedNode = globalStore.get(layoutModel.focusedNode);
return focusedNode.data?.blockId;
}

function getSimpleControlShiftAtom() {
return simpleControlShiftAtom;
}
Expand Down Expand Up @@ -161,12 +168,6 @@ function appHandleKeyDown(waveEvent: WaveKeyboardEvent): boolean {
const blockId = focusedNode?.data?.blockId;
if (blockId != null && shouldDispatchToBlock(waveEvent)) {
const bcm = getBlockComponentModel(blockId);
if (bcm.openSwitchConnection != null) {
if (keyutil.checkKeyPressed(waveEvent, "Cmd:g")) {
bcm.openSwitchConnection();
return true;
}
}
const viewModel = bcm?.viewModel;
if (viewModel?.keyDownHandler) {
const handledByBlock = viewModel.keyDownHandler(waveEvent);
Expand Down Expand Up @@ -262,6 +263,13 @@ function registerGlobalKeys() {
switchBlockInDirection(tabId, NavigateDirection.Right);
return true;
});
globalKeyMap.set("Cmd:g", () => {
const bcm = getBlockComponentModel(getFocusedBlockInActiveTab());
if (bcm.openSwitchConnection != null) {
bcm.openSwitchConnection();
return true;
}
});
for (let idx = 1; idx <= 9; idx++) {
globalKeyMap.set(`Cmd:${idx}`, () => {
switchTabAbs(idx);
Expand Down

0 comments on commit c34fa96

Please sign in to comment.