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

...
Автор SHA1 Повідомлення Дата
l0ng-ai 8b63b58feb fix(vcs): expire the conflict notice once the merge or rebase is over
"All conflicts resolved" kept its Commit… and Abort Merge actions after the
merge was committed, and Abort Merge then reported no merge in progress. The
conflict notices (key vcs.conflicts) now expire when the repository leaves
the merge, rebase, cherry-pick, revert or am they refer to, however it ended.

Fixes #4154
2026-11-18 18:53:28 +08:00
l0ng-ai 71090202b6 fix(debugger): Breakpoints dialog selects on click and keeps typed conditions (#4249)
A single click on a breakpoint jumped to its source and closed the dialog,
and a condition typed and confirmed with Enter (Done) was lost, as only
leaving the field saved it. A click now selects the breakpoint (double-click
or Enter goes to the source), and the shown breakpoint's typed fields are
saved when the dialog closes or another breakpoint is shown, for method and
field breakpoints too; unchanged fields are not written again.

Fixes #4150
2026-11-18 18:52:04 +08:00
5 змінених файлів з 160 додано та 11 видалено

No files matched your search

+57
Переглянути файл
@@ -0,0 +1,57 @@
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { act, cleanup, fireEvent, render, screen, within } from "@testing-library/react";
import { provideEditorService } from "@/workbench/contributions";
import { addBreakpoint, useBreakpoints } from "../breakpoints/store";
import { DebuggerOverlays } from "../ui/Overlays";
import { useOverlays } from "../ui/popoverStore";
const openFile = vi.fn(async () => undefined);
provideEditorService({ openFile } as never);
const path = "/p/main.py";
describe("the Breakpoints dialog", () => {
beforeEach(() => {
openFile.mockClear();
useBreakpoints.setState({ byFile: {}, status: {}, muted: false });
const first = addBreakpoint(path, 2, { condition: "value == 2" });
addBreakpoint(path, 6);
useOverlays.setState({ breakpoints: { id: first.id } } as never);
});
afterEach(() => {
cleanup();
act(() => useOverlays.setState({ breakpoints: null } as never));
});
const dialog = () => screen.getByRole("dialog", { name: "Breakpoints" });
const row = (name: string) => within(within(dialog()).getByLabelText("All breakpoints")).getByText(name);
const condition = () => within(dialog()).getByLabelText("Condition") as HTMLInputElement;
/** A row's mouse click as the list sees it: mousedown selects, click (with its count) activates. */
const clickRow = (name: string, detail: number) => {
fireEvent.mouseDown(row(name), { button: 0 });
fireEvent.click(row(name), { detail });
};
const breakpointAt = (line: number) => useBreakpoints.getState().byFile[path]!.find((b) => b.line === line)!;
it("selects a breakpoint on click and goes to its source on double-click", () => {
render(<DebuggerOverlays />);
clickRow("main.py:7", 1);
expect(openFile).not.toHaveBeenCalled();
// Its details show beside the list.
expect(within(dialog()).getAllByText("main.py:7")).toHaveLength(2);
clickRow("main.py:3", 2);
expect(openFile).toHaveBeenCalledWith(path, { selection: { line: 2, col: 0 } });
});
it("saves the condition being typed when the dialog closes or another breakpoint is shown", () => {
render(<DebuggerOverlays />);
fireEvent.change(condition(), { target: { value: "value == 1" } });
fireEvent.click(within(dialog()).getByRole("button", { name: "Done" }));
expect(breakpointAt(2).condition).toBe("value == 1");
act(() => useOverlays.setState({ breakpoints: { id: breakpointAt(2).id } } as never));
fireEvent.change(condition(), { target: { value: "value == 3" } });
clickRow("main.py:7", 1);
expect(breakpointAt(2).condition).toBe("value == 3");
});
});
+58 -10
Переглянути файл
@@ -179,12 +179,19 @@ function BreakpointFields({
const commitText = () => {
const d = draft.current;
const cond = d.condition.trim() || null;
if (cond) pushHistory("condition", cond);
updateBreakpoint(path, bp.id, {
const changes = {
condition: cond,
hitCondition: d.hitCondition.trim() || null,
logMessage: d.logEval ? d.logMessage.trim() || null : null,
});
};
if (
changes.condition === (bp.condition ?? null) &&
changes.hitCondition === (bp.hitCondition ?? null) &&
changes.logMessage === (bp.logMessage ?? null)
)
return;
if (cond) pushHistory("condition", cond);
updateBreakpoint(path, bp.id, changes);
};
useEffect(() => {
if (!commitRef) return;
@@ -396,9 +403,13 @@ function BreakpointsDialog() {
}, [byFile, methods, fields]);
const items = rows.filter((r) => r.type !== "section");
const [selected, setSelected] = useState<string | null>(null);
// The shown breakpoint's typed fields, saved before it is closed or another one is shown:
// Enter on Done and a click on a row don't blur them.
const commitRef = useRef<(() => void) | null>(null);
const open = !!state;
const current = items.find((r) => r.key === (selected ?? state?.id)) ?? items[0];
const close = () => {
commitRef.current?.();
setSelected(null);
useOverlays.setState({ breakpoints: null });
};
@@ -448,8 +459,14 @@ function BreakpointsDialog() {
isSection={(r) => r.type === "section"}
renderSection={(r) => <div className={styles.exceptionAdapter}>{r.type === "section" ? r.label : ""}</div>}
activeIndex={current ? rows.indexOf(current) : -1}
onActiveChange={(i) => setSelected(rows[i]?.key ?? null)}
onActivate={(r) => goTo(r)}
onActiveChange={(i) => {
commitRef.current?.();
setSelected(rows[i]?.key ?? null);
}}
// A click selects; double-click or Enter goes to the source.
onActivate={(r, _i, e) => {
if (e.type === "keydown" || e.detail > 1) goTo(r);
}}
aria-label="All breakpoints"
className={styles.bpList}
empty={
@@ -522,9 +539,9 @@ function BreakpointsDialog() {
</div>
<div className={styles.bpDetail}>
{current?.type === "line" ? (
<BreakpointDetail key={current.key} row={current} onGo={() => goTo(current)} />
<BreakpointDetail key={current.key} row={current} onGo={() => goTo(current)} commitRef={commitRef} />
) : current?.type === "special" ? (
<SpecialDetail key={current.key} bp={current.bp} onGo={() => goTo(current)} />
<SpecialDetail key={current.key} bp={current.bp} onGo={() => goTo(current)} commitRef={commitRef} />
) : null}
</div>
</div>
@@ -579,7 +596,15 @@ function ExceptionBreakpoints({ open }: { open: boolean }) {
);
}
function BreakpointDetail({ row, onGo }: { row: BpRow; onGo: () => void }) {
function BreakpointDetail({
row,
onGo,
commitRef,
}: {
row: BpRow;
onGo: () => void;
commitRef: MutableRefObject<(() => void) | null>;
}) {
const { path, bp } = row;
const st = useBreakpoints((s) => s.status[bp.id]);
return (
@@ -597,7 +622,7 @@ function BreakpointDetail({ row, onGo }: { row: BpRow; onGo: () => void }) {
</Button>
</div>
{st && <div className={styles.statusLine}>{st.verified ? tx("Verified") : (st.message ?? "Not verified")}</div>}
<BreakpointFields path={path} bp={bp} />
<BreakpointFields path={path} bp={bp} commitRef={commitRef} />
<Checkbox
checked={!!bp.temporary}
onChange={(temporary) => updateBreakpoint(path, bp.id, { temporary })}
@@ -607,11 +632,34 @@ function BreakpointDetail({ row, onGo }: { row: BpRow; onGo: () => void }) {
);
}
function SpecialDetail({ bp, onGo }: { bp: SpecialBreakpoint; onGo: () => void }) {
function SpecialDetail({
bp,
onGo,
commitRef,
}: {
bp: SpecialBreakpoint;
onGo: () => void;
commitRef: MutableRefObject<(() => void) | null>;
}) {
const st = useSpecialBreakpoints((s) => s.status[bp.id]);
const [name, setName] = useState(bp.kind === "method" ? bp.name : bp.label);
const [condition, setCondition] = useState(bp.condition ?? "");
const [hitCondition, setHitCondition] = useState(bp.hitCondition ?? "");
const draft = useRef({ name, condition, hitCondition });
useEffect(() => {
draft.current = { name, condition, hitCondition };
commitRef.current = () => {
const d = draft.current;
updateSpecial(bp.id, {
name: d.name.trim(),
condition: d.condition.trim() || null,
hitCondition: d.hitCondition.trim() || null,
});
};
return () => {
commitRef.current = null;
};
});
return (
<div className={styles.detail}>
<div className={styles.bpTitle}>
+32
Переглянути файл
@@ -0,0 +1,32 @@
import { afterEach, beforeEach, expect, it, vi } from "vitest";
import type { BranchInfo } from "@/bindings";
import { installOperationNoticeExpiry } from "../operations";
import { useVcs } from "../store";
const { expire } = vi.hoisted(() => ({ expire: vi.fn() }));
vi.mock("@/workbench/contributions", async (original) => ({
...(await original<typeof import("@/workbench/contributions")>()),
notifications: () => ({ notify: vi.fn(), expire }),
}));
const branch = (operation: string | null) => ({ head: "main", operation }) as unknown as BranchInfo;
let dispose: () => void;
beforeEach(() => {
expire.mockClear();
useVcs.setState({ branch: branch("merge") });
dispose = installOperationNoticeExpiry();
});
afterEach(() => dispose());
it("expires the conflict notice once the merge it offers to commit or abort is over", () => {
useVcs.setState({ branch: branch("merge") });
expect(expire).not.toHaveBeenCalled();
useVcs.setState({ branch: branch(null) });
expect(expire).toHaveBeenCalledWith("vcs.conflicts");
});
it("keeps it while an operation is still in progress", () => {
useVcs.setState({ branch: branch("rebase") });
expect(expire).not.toHaveBeenCalled();
});
+2 -1
Переглянути файл
@@ -20,7 +20,7 @@ import { registerVcsActions } from "./actions";
import { installChangelists } from "./changelists";
import { registerHistoryActions, trackOperationContext } from "./historyActions";
import { registerLogPaneActions } from "./logPaneActions";
import { controlLabel, controlOperation, inProgress } from "./operations";
import { controlLabel, controlOperation, inProgress, installOperationNoticeExpiry } from "./operations";
import { annotationsShown, blameSlot } from "./blame";
import { activateRevisionAnnotations } from "./annotateRevisionProvider";
import { inlineBlame } from "./inlineBlame";
@@ -195,6 +195,7 @@ export function activate(): () => void {
useCommit.setState({ signOff: workflowSettings().vcs.git.signOff });
const disposers = [
installVcsStore(),
installOperationNoticeExpiry(),
installRootSync(),
installGitLog(),
installDiagnosticsTracking(),
+11
Переглянути файл
@@ -56,6 +56,17 @@ export function inProgress(op: string | null | undefined = useVcs.getState().bra
return op === "rebase" || op === "merge" || op === "cherry-pick" || op === "revert" || op === "am" ? op : null;
}
/**
* Expires the conflict notices (key `vcs.conflicts`: Merge conflicts, All conflicts resolved) once
* the merge / rebase / cherry-pick they offer to continue or abort is over, however it ended.
*/
export function installOperationNoticeExpiry(): () => void {
return useVcs.subscribe((s, prev) => {
if (inProgress(prev.branch?.operation) && !inProgress(s.branch?.operation))
notifications().expire?.("vcs.conflicts");
});
}
/** "Rebasing main", "Merging", "Cherry-picking"… for the branch widget and banner. */
export function operationTitle(op: InProgress, head: string | null): string {
if (!head)