Порівняти коміти

...
Автор SHA1 Повідомлення Дата
l0ng-ai 2bddc99513 fix(vcs): collapsing a file in the all-files diff keeps its unsaved edits 2026-11-16 18:42:43 +08:00
3 змінених файлів з 20 додано та 12 видалено

No files matched your search

+3
Переглянути файл
@@ -71,6 +71,9 @@
display: flex;
flex-direction: column;
}
.body[hidden] {
display: none;
}
/* Space a block takes before its diff loads, so the scrollbar is roughly right. */
.placeholder {
height: 160px;
+9 -8
Переглянути файл
@@ -98,14 +98,15 @@ function Block({
/>
)}
</div>
{!collapsed &&
(near ? (
<div className={styles.body}>
<DiffEditor input={input} fit />
</div>
) : (
<div className={styles.placeholder} />
))}
{/* A collapsed block keeps its loaded diff, hidden: unmounting it would release the
working-tree document and, with autosave off, drop its unsaved edits. */}
{near ? (
<div className={styles.body} hidden={collapsed}>
<DiffEditor input={input} fit />
</div>
) : (
!collapsed && <div className={styles.placeholder} />
)}
</section>
);
}
+8 -4
Переглянути файл
@@ -83,20 +83,24 @@ describe("the all-in-one diff tab", () => {
expect(screen.getAllByText("src")).toHaveLength(2);
});
it("collapses a file and all files", () => {
it("collapses a file and all files, keeping their diffs (and unsaved edits) loaded", () => {
render(<CombinedDiffTab input={input} />);
const shown = () => screen.queryAllByTestId("block-diff").filter((b) => !b.closest("[hidden]"));
const first = screen.getAllByTestId("block-diff")[0]!;
act(() => {
fireEvent.click(screen.getAllByRole("button", { name: "Collapse File" })[0]!);
});
expect(screen.getAllByTestId("block-diff")).toHaveLength(2);
expect(shown()).toHaveLength(2);
act(() => {
fireEvent.click(screen.getByRole("button", { name: "Collapse All Files" }));
});
expect(screen.queryAllByTestId("block-diff")).toHaveLength(0);
expect(shown()).toHaveLength(0);
act(() => {
fireEvent.click(screen.getByRole("button", { name: "Expand All Files" }));
});
expect(screen.getAllByTestId("block-diff")).toHaveLength(3);
expect(shown()).toHaveLength(3);
// The same diff all along: collapsing never released its document.
expect(screen.getAllByTestId("block-diff")[0]).toBe(first);
});
it("switches every block between side-by-side and unified", () => {