Skip to content

Commit 316e180

Browse files
committed
fix(pull-requests): expand code tab diffs by default
1 parent 43bafd4 commit 316e180

2 files changed

Lines changed: 11 additions & 12 deletions

File tree

‎apps/web/src/components/pullRequest/pullRequestDiff.logic.test.ts‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ describe("isLineInFileDiff", () => {
5050
describe("isFileDiffCollapsed", () => {
5151
const NO_TOGGLES: ReadonlySet<string> = new Set();
5252

53-
it("folds every file before the reader has touched anything", () => {
54-
expect(isFileDiffCollapsed("a.ts", null, NO_TOGGLES)).toBe(true);
55-
expect(isFileDiffCollapsed("b.ts", null, NO_TOGGLES)).toBe(true);
53+
it("opens every file before the reader has touched anything", () => {
54+
expect(isFileDiffCollapsed("a.ts", null, NO_TOGGLES)).toBe(false);
55+
expect(isFileDiffCollapsed("b.ts", null, NO_TOGGLES)).toBe(false);
5656
});
5757

5858
it("opens every file once the toolbar has asked for it", () => {
@@ -66,12 +66,12 @@ describe("isFileDiffCollapsed", () => {
6666
expect(isFileDiffCollapsed("b.ts", "folded", NO_TOGGLES)).toBe(true);
6767
});
6868

69-
it("keeps a file the reader opened open as the next slice arrives", () => {
70-
// The file keys grow with every slice, so the answer for one already open must not depend on
71-
// how many of them there are by then.
69+
it("keeps a file the reader folded closed as the next slice arrives", () => {
70+
// The file keys grow with every slice, so the answer for one already folded must not depend
71+
// on how many of them there are by then.
7272
const toggled = new Set(["b.ts"]);
73-
expect(isFileDiffCollapsed("b.ts", null, toggled)).toBe(false);
74-
expect(isFileDiffCollapsed("c.ts", null, toggled)).toBe(true);
73+
expect(isFileDiffCollapsed("b.ts", null, toggled)).toBe(true);
74+
expect(isFileDiffCollapsed("c.ts", null, toggled)).toBe(false);
7575
});
7676

7777
it("still answers to a toggle after either toolbar press", () => {

‎apps/web/src/components/pullRequest/pullRequestDiff.logic.ts‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,14 @@ export type DiffFoldOverride = "expanded" | "folded" | null;
3030
* A diff arrives a slice at a time, so the reader's own choices are kept as the difference from
3131
* what the toolbar last said rather than as the set of folded files: a file that has not loaded
3232
* yet cannot be in a set, and would otherwise land expanded moments after the reader folded
33-
* everything. Folded is the starting point whatever the change's size, because laying out every
34-
* file of it costs the reader the seconds before the tab is usable and buries the file they came
35-
* for among the ones they did not.
33+
* everything. Files start expanded so opening the Code tab immediately shows the change; the
34+
* reader can still fold individual files or the whole diff from the toolbar.
3635
*/
3736
export function isFileDiffCollapsed(
3837
fileKey: string,
3938
foldOverride: DiffFoldOverride,
4039
toggledFileKeys: ReadonlySet<string>,
4140
): boolean {
42-
const foldedByDefault = foldOverride !== "expanded";
41+
const foldedByDefault = foldOverride === "folded";
4342
return toggledFileKeys.has(fileKey) ? !foldedByDefault : foldedByDefault;
4443
}

0 commit comments

Comments
 (0)