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

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