Skip to content

Commit 47fd70d

Browse files
committed
fix(desktop): interrupted quit press no longer counts toward double-tap
1 parent a809627 commit 47fd70d

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

‎apps/desktop/src/window/QuitHold.test.ts‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,17 @@ describe("makeQuitHoldHandler", () => {
171171
expect(harness.quit).not.toHaveBeenCalled();
172172
});
173173

174+
it("does not count an interrupted press toward a double tap", async () => {
175+
const harness = makeHarness();
176+
await harness.send(makeInput({}));
177+
await harness.send(makeInput({ shift: true }));
178+
// A fresh press right after the interruption starts a new hold, not a
179+
// double-tap quit.
180+
await harness.send(makeInput({}));
181+
expect(harness.quit).not.toHaveBeenCalled();
182+
expect(harness.notifications).toEqual(["down", "up", "down"]);
183+
});
184+
174185
it("ignores other shortcuts", async () => {
175186
const harness = makeHarness();
176187
await harness.send(makeInput({ key: "w" }));

‎apps/desktop/src/window/QuitHold.ts‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,14 @@ export function makeQuitHoldHandler(
8686
if (!modifierDown || input.alt || input.shift || key !== "q") {
8787
// Any other key (or an extra modifier) pressed mid-hold breaks the
8888
// gesture; without this the hold timer keeps running through the
89-
// interruption and the next qualifying repeat would quit early.
90-
if (holding && !input.isAutoRepeat) release();
89+
// interruption and the next qualifying repeat would quit early. The
90+
// interrupted press also stops counting toward a double tap — but only
91+
// here, not in release(), which runs mid-restart on an unseen-release
92+
// re-press and must not wipe that press's own tap timestamp.
93+
if (holding && !input.isAutoRepeat) {
94+
lastPressAt = 0;
95+
release();
96+
}
9197
return;
9298
}
9399

0 commit comments

Comments
 (0)