Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/quit-with-q-only.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"hunkdiff": patch
---

Stop treating Escape as a global quit shortcut; use `q` to quit while preserving Escape for dialogs and focused controls.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Or with Homebrew:
```bash
brew install hunk
```

> [!NOTE]
> If you previously installed hunk via `modem-dev/tap`, be sure to uninstall it first with `brew uninstall modem-dev/tap/hunk`.

Expand Down
44 changes: 43 additions & 1 deletion src/ui/AppHost.interactions.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3356,7 +3356,7 @@ describe("App interactions", () => {
}
});

test("quit shortcuts route through the provided onQuit handler in regular and pager modes", async () => {
test("q routes through the provided onQuit handler in regular and pager modes", async () => {
const regularQuit = mock(() => undefined);
const regularSetup = await testRender(
<AppHost bootstrap={createBootstrap()} onQuit={regularQuit} />,
Expand Down Expand Up @@ -3397,4 +3397,46 @@ describe("App interactions", () => {
});
}
});

test("Escape does not quit in regular or pager modes", async () => {
const regularQuit = mock(() => undefined);
const regularSetup = await testRender(
<AppHost bootstrap={createBootstrap()} onQuit={regularQuit} />,
{ width: 220, height: 24 },
);

try {
await flush(regularSetup);
await act(async () => {
await regularSetup.mockInput.pressEscape();
});
await flush(regularSetup);

expect(regularQuit).toHaveBeenCalledTimes(0);
} finally {
await act(async () => {
regularSetup.renderer.destroy();
});
}

const pagerQuit = mock(() => undefined);
const pagerSetup = await testRender(
<AppHost bootstrap={createBootstrap("auto", true)} onQuit={pagerQuit} />,
{ width: 180, height: 20 },
);

try {
await flush(pagerSetup);
await act(async () => {
await pagerSetup.mockInput.pressEscape();
});
await flush(pagerSetup);

expect(pagerQuit).toHaveBeenCalledTimes(0);
} finally {
await act(async () => {
pagerSetup.renderer.destroy();
});
}
});
});
7 changes: 1 addition & 6 deletions src/ui/hooks/useAppKeyboardShortcuts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ export function useAppKeyboardShortcuts({
return;
}

if (key.name === "q" || isEscapeKey(key)) {
if (key.name === "q") {
requestQuit();
return;
}
Expand Down Expand Up @@ -415,11 +415,6 @@ export function useAppKeyboardShortcuts({
return;
}

if (isEscapeKey(key)) {
requestQuit();
return;
}

if (key.name === "tab") {
toggleFocusArea();
return;
Expand Down