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/ctrl-half-page-navigation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"hunkdiff": patch
---

Add Ctrl-D and Ctrl-U aliases for half-page review scrolling.
4 changes: 2 additions & 2 deletions docs/keybindings.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ The built-in commands and the keys they ship with:
| `hunk.review.alignCurrentLineTop` | Align current line to viewport top | _(none)_ |
| `hunk.review.editSelectedFile` | Open the selected file in your editor | `e` |
| `hunk.review.focusFilter` | Focus the file filter | `/` |
| `hunk.review.halfPageDown` | Scroll down half a page | `d` |
| `hunk.review.halfPageUp` | Scroll up half a page | `u` |
| `hunk.review.halfPageDown` | Scroll down half a page | `d`, `ctrl+d` |
| `hunk.review.halfPageUp` | Scroll up half a page | `u`, `ctrl+u` |
| `hunk.review.jumpToBottom` | Jump to end | `G`, `end` |
| `hunk.review.jumpToTop` | Jump to start | `g`, `home` |
| `hunk.review.nextAnnotatedFile` | Next annotated file | _(none)_ |
Expand Down
4 changes: 2 additions & 2 deletions src/core/run/commandCatalog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ const BUILTIN_COMMANDS = [
id: "hunk.review.halfPageDown",
title: "Scroll down half a page",
category: "review",
defaultKeys: ["d"],
defaultKeys: ["d", "ctrl+d"],
locus: "client-local",
verticalDirection: 1,
publicToExtensions: true,
Expand All @@ -190,7 +190,7 @@ const BUILTIN_COMMANDS = [
id: "hunk.review.halfPageUp",
title: "Scroll up half a page",
category: "review",
defaultKeys: ["u"],
defaultKeys: ["u", "ctrl+u"],
locus: "client-local",
verticalDirection: -1,
publicToExtensions: true,
Expand Down
12 changes: 12 additions & 0 deletions src/ui/lib/appCommands.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ describe("built-in command chords", () => {
expect(press({ name: "up" })).toBe("hunk.review.stepUp");
expect(press({ name: "k", sequence: "k" })).toBe("hunk.review.stepUp");
expect(press({ name: "d", sequence: "d" })).toBe("hunk.review.halfPageDown");
expect(press({ name: "d", ctrl: true })).toBe("hunk.review.halfPageDown");
expect(press({ name: "u", sequence: "u" })).toBe("hunk.review.halfPageUp");
expect(press({ name: "u", ctrl: true })).toBe("hunk.review.halfPageUp");
expect(ran).toEqual([
"scrollDiff:1,viewport",
"scrollDiff:1,viewport",
Expand All @@ -108,6 +110,8 @@ describe("built-in command chords", () => {
"stepDiffLine:-1",
"stepDiffLine:-1",
"scrollDiff:1,half",
"scrollDiff:1,half",
"scrollDiff:-1,half",
"scrollDiff:-1,half",
]);
});
Expand Down Expand Up @@ -256,6 +260,14 @@ describe("builtinCommandKeyDefaults", () => {
"space",
"f",
]);
expect(defaults.find((entry) => entry.id === "hunk.review.halfPageDown")?.defaultKeys).toEqual([
"d",
"ctrl+d",
]);
expect(defaults.find((entry) => entry.id === "hunk.review.halfPageUp")?.defaultKeys).toEqual([
"u",
"ctrl+u",
]);
// The menu-only commands ship unbound, and are reported so users can bind them.
expect(
defaults
Expand Down
4 changes: 2 additions & 2 deletions test/pty/pager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ describe("PTY pager", () => {
expect(initial).toContain("before_01");
expect(initial).not.toContain("before_12");

await session.press("d");
await session.press(["ctrl", "d"]);
const halfPaged = await harness.waitForSnapshot(
session,
(text) => !text.includes("before_01"),
Expand All @@ -91,7 +91,7 @@ describe("PTY pager", () => {

expect(halfPaged).not.toContain("before_01");

await session.press("u");
await session.press(["ctrl", "u"]);
const halfPageRestored = await harness.waitForSnapshot(
session,
(text) => text.includes("before_01"),
Expand Down
Loading