diff --git a/scm-ui/ui-components/src/repos/DiffExpander.test.ts b/scm-ui/ui-components/src/repos/DiffExpander.test.ts index cefeb7085d..fcdaaa79f7 100644 --- a/scm-ui/ui-components/src/repos/DiffExpander.test.ts +++ b/scm-ui/ui-components/src/repos/DiffExpander.test.ts @@ -289,9 +289,12 @@ describe("with hunks the diff expander", () => { expect(fetchMock.done()).toBe(true); expect(newFile!.hunks!.length).toBe(oldHunkCount + 1); expect(newFile!.hunks![1]).toBe(expandedHunk); - const newHunk = newFile!.hunks![2].changes; - expect(newHunk.length).toBe(1); - expect(newHunk[0].content).toBe("new line 1"); + + const newHunk = newFile!.hunks![2]; + expect(newHunk.changes.length).toBe(1); + expect(newHunk.changes[0].content).toBe("new line 1"); + expect(newHunk.expansion).toBe(true); + expect(newFile!.hunks![3]).toBe(subsequentHunk); }); it("should create new hunk with new line from api client at the top", async () => { @@ -313,16 +316,18 @@ describe("with hunks the diff expander", () => { expect(newFile!.hunks![0]).toBe(preceedingHunk); expect(newFile!.hunks![2]).toBe(expandedHunk); - expect(newFile!.hunks![1].changes.length).toBe(5); - expect(newFile!.hunks![1].changes[0].content).toBe("new line 9"); - expect(newFile!.hunks![1].changes[0].oldLineNumber).toBe(9); - expect(newFile!.hunks![1].changes[0].newLineNumber).toBe(9); - expect(newFile!.hunks![1].changes[1].content).toBe("new line 10"); - expect(newFile!.hunks![1].changes[1].oldLineNumber).toBe(10); - expect(newFile!.hunks![1].changes[1].newLineNumber).toBe(10); - expect(newFile!.hunks![1].changes[4].content).toBe("new line 13"); - expect(newFile!.hunks![1].changes[4].oldLineNumber).toBe(13); - expect(newFile!.hunks![1].changes[4].newLineNumber).toBe(13); + const newHunk = newFile!.hunks![1]; + expect(newHunk.changes.length).toBe(5); + expect(newHunk.changes[0].content).toBe("new line 9"); + expect(newHunk.changes[0].oldLineNumber).toBe(9); + expect(newHunk.changes[0].newLineNumber).toBe(9); + expect(newHunk.changes[1].content).toBe("new line 10"); + expect(newHunk.changes[1].oldLineNumber).toBe(10); + expect(newHunk.changes[1].newLineNumber).toBe(10); + expect(newHunk.changes[4].content).toBe("new line 13"); + expect(newHunk.changes[4].oldLineNumber).toBe(13); + expect(newHunk.changes[4].newLineNumber).toBe(13); + expect(newHunk.expansion).toBe(true); }); it("should set fully expanded to true if expanded completely", async () => { const oldHunkCount = diffExpander.hunkCount(); diff --git a/scm-ui/ui-components/src/repos/DiffExpander.ts b/scm-ui/ui-components/src/repos/DiffExpander.ts index 9b94daec15..f21834c174 100644 --- a/scm-ui/ui-components/src/repos/DiffExpander.ts +++ b/scm-ui/ui-components/src/repos/DiffExpander.ts @@ -133,7 +133,8 @@ class DiffExpander { newStart: minNewLineNumberOfNewHunk, oldLines: lines.length, newLines: lines.length, - changes: newChanges + changes: newChanges, + expansion: true }; const newHunks: Hunk[] = []; this.file.hunks!.forEach((oldHunk: Hunk, i: number) => { @@ -178,6 +179,7 @@ class DiffExpander { newStart: maxNewLineNumberFromPrecedingHunk + 1, oldLines: lines.length, newLines: lines.length, + expansion: true, fullyExpanded: requestedLines < 0 || lines.length < requestedLines }; diff --git a/scm-ui/ui-components/src/repos/DiffTypes.ts b/scm-ui/ui-components/src/repos/DiffTypes.ts index 23afd3349d..cd004ccd44 100644 --- a/scm-ui/ui-components/src/repos/DiffTypes.ts +++ b/scm-ui/ui-components/src/repos/DiffTypes.ts @@ -58,6 +58,7 @@ export type Hunk = { oldLines?: number; newLines?: number; fullyExpanded?: boolean; + expansion?: boolean; }; export type ChangeType = "insert" | "delete" | "normal" | "conflict";