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
55 changes: 51 additions & 4 deletions src/ui/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,23 @@ function AppShell({
};

/** Scroll the main review pane by line steps, viewport fractions, or whole-content jumps. */
const scrollDiff = (delta: number, unit: "step" | "viewport" | "content" = "viewport") => {
const scrollDiff = (
delta: number,
unit: "step" | "viewport" | "content" | "half" = "viewport",
) => {
if (unit === "half") {
const scrollBox = diffScrollRef.current;
if (!scrollBox) return;

// Calculate half the viewport height
const viewportHeight = scrollBox.viewport?.height ?? 20;
const scrollAmount = Math.floor(viewportHeight / 2);

// Use scrollTo with current position + delta * amount
const currentScroll = scrollBox.scrollTop;
scrollBox.scrollTo(currentScroll + delta * scrollAmount);
return;
}
diffScrollRef.current?.scrollBy(delta, unit);
};

Expand Down Expand Up @@ -571,11 +587,22 @@ function AppShell({

useKeyboard((key: KeyEvent) => {
const pageDownKey =
key.name === "pagedown" || key.name === "space" || key.name === " " || key.sequence === " ";
key.name === "pagedown" ||
key.name === "space" ||
key.name === " " ||
key.sequence === " " ||
key.name === "f" ||
key.sequence === "f";
const pageUpKey = key.name === "pageup" || key.name === "b" || key.sequence === "b";
const stepDownKey = key.name === "down" || key.name === "j" || key.sequence === "j";
const stepUpKey = key.name === "up" || key.name === "k" || key.sequence === "k";

// New shortcuts from issue #101 - using less/git diff conventions
const halfPageDownKey = key.name === "d" || key.sequence === "d";
const halfPageUpKey = key.name === "u" || key.sequence === "u";
const shiftSpacePageUpKey =
key.shift && (key.name === "space" || key.name === " " || key.sequence === " ");

if (key.name === "f10") {
if (pagerMode) {
return;
Expand All @@ -600,11 +627,21 @@ function AppShell({
return;
}

if (pageUpKey) {
if (pageUpKey || shiftSpacePageUpKey) {
scrollDiff(-1, "viewport");
return;
}

if (halfPageDownKey) {
scrollDiff(1, "half");
return;
}

if (halfPageUpKey) {
scrollDiff(-1, "half");
return;
}

if (stepDownKey) {
scrollDiff(1, "step");
return;
Expand Down Expand Up @@ -716,11 +753,21 @@ function AppShell({
return;
}

if (pageUpKey) {
if (pageUpKey || shiftSpacePageUpKey) {
scrollDiff(-1, "viewport");
return;
}

if (halfPageDownKey) {
scrollDiff(1, "half");
return;
}

if (halfPageUpKey) {
scrollDiff(-1, "half");
return;
}

if (key.name === "home") {
scrollDiff(-1, "content");
return;
Expand Down
5 changes: 4 additions & 1 deletion src/ui/components/chrome/HelpDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ export function HelpDialog({
title: "Navigation",
items: [
["↑ / ↓", "move line-by-line"],
["Space / b", "page down / page up"],
["Space / f", "page down (alt: f)"],
["b", "page up"],
["Shift+Space", "page up (alt)"],
["d / u", "half page down / up"],
["[ / ]", "previous / next hunk"],
["Home / End", "jump to top / bottom"],
],
Expand Down
Loading