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

..
Автор SHA1 Повідомлення Дата
l0ng-ai be9b00a255 fix(vcs): the staging area commits a staged addition deleted from disk 2026-11-16 18:45:50 +08:00
l0ng-ai f74bc7abac fix(vcs): collapsing a file in the all-files diff keeps its unsaved edits (#3739)
Collapsing a block unmounted its diff editor and released the working-tree document, which with autosave off drops its unsaved edits. A loaded block now keeps its diff while collapsed, hidden.
2026-11-16 18:43:09 +08:00
l0ng-ai c871c164c1 fix(ui): editor hints and balloons stay inside the window (#3738)
An editor hint is the tooltip element itself, so the editor theme's .cm-tooltip max-width (same specificity, loaded later) replaced its 480 px limit and long messages ran past the window edge; the limit now applies to .cm-tooltip.cm-lsp-hint. The balloon stack keeps 16 px from the left as well and balloons narrow to fit, so they are no longer cut off in a narrow window.
2026-11-16 18:40:53 +08:00
l0ng-ai db65b12afe fix(app): Close Project asks about untitled buffers instead of dropping them (#3737)
The unsaved-changes guard left untitled buffers out because they follow the window into another project opened in place, but it also ran for Close Project, Disconnect from Remote Host, closing to Welcome and opening a remote project in place, where they don't follow, so they were dropped without a question. The guard now knows where the window goes; only another local project in place leaves them alone, otherwise they count, Save asks for their paths and a cancelled Save As keeps the project open.
2026-11-16 18:37:29 +08:00
10 змінених файлів з 72 додано та 20 видалено

No files matched your search

+2 -1
Переглянути файл
@@ -295,9 +295,10 @@ export const lspTheme = EditorView.theme({
padding: "6px 10px",
borderRadius: "var(--radius-popup)",
boxShadow: "var(--shadow-popup)",
maxWidth: "480px",
whiteSpace: "pre-wrap",
},
// The hint is the tooltip element itself: beat the editor theme's `.cm-tooltip` width.
".cm-tooltip.cm-lsp-hint": { maxWidth: "min(480px, 100%)" },
".cm-lsp-hint-error": {
backgroundColor: "var(--bg-feedback-error, color-mix(in srgb, var(--danger) 8%, var(--bg-popup)))",
borderColor: "color-mix(in srgb, var(--danger) 35%, var(--border-popup))",
+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", () => {
+20
Переглянути файл
@@ -59,6 +59,26 @@ describe("staging area inclusion", () => {
expect(plan.stage).toEqual(["/p/src/Unstaged.kt", "/p/src/Gone.kt"]);
});
it("lists and commits a staged addition deleted from disk; the change lists leave it out", () => {
const gone = file("src/New.txt", "added", "deleted");
const status = [gone, unstagedOnly];
expect(isCommitAll(status)).toBe(false);
const plan = planCommit(status, stagingChecks(status));
expect(plan.included.map((f) => f.relPath)).toEqual(["src/New.txt"]);
expect(plan.exclude).toEqual([]);
// Staged shows the addition, Unstaged the deletion.
const tree = buildChangeTree(status, "/p", false, undefined, [], true);
const kinds = (group: string) =>
tree.find((n) => n.group === group)?.children?.flatMap((n) => (n.label === "New.txt" ? [n.kind] : []));
expect(kinds("staged")).toEqual(["added"]);
expect(kinds("unstaged")).toEqual(["deleted"]);
// Without the staging area it is no change against HEAD: listed nowhere, never committed.
expect(buildChangeTree(status, "/p", false).flatMap((n) => n.files.map((f) => f.relPath))).toEqual([
"src/Unstaged.kt",
]);
expect(planCommit(status, new Map([[unstagedOnly.path, "all" as const]])).exclude).toEqual(["/p/src/New.txt"]);
});
it("is not Commit All when only unversioned files changed", () => {
expect(isCommitAll([untracked])).toBe(false);
});
+5 -2
Переглянути файл
@@ -4,7 +4,7 @@ import type { FileStatus, Stash } from "@/bindings";
import { call, commands } from "@/platform/ipc";
import { Checkbox, Dialog, Icon, IconButton, Input, T, fileIconName } from "@/ui";
import { notifications } from "@/workbench/contributions";
import { groupOf, remainingOverrides, renamedFromPath } from "./changes";
import { addedThenDeleted, groupOf, remainingOverrides, renamedFromPath } from "./changes";
import { runCommitChecks } from "./commitChecks";
import { contributedCheckProblems, currentPlan, selectionOf } from "./commitSelection";
import { forgetAmendDraft, keepMessageAfterCommit, rememberMessage, useCommit } from "./commitStore";
@@ -54,7 +54,10 @@ export async function commitChanges(): Promise<string | undefined> {
});
return undefined;
}
const candidates = plan.included.map((f) => ({ path: stripSlash(f.path), exists: effectiveKind(f) !== "deleted" }));
const candidates = plan.included.map((f) => ({
path: stripSlash(f.path),
exists: effectiveKind(f) !== "deleted" && !addedThenDeleted(f),
}));
// IDEA: failed checks show in the commit panel; the next Commit ("Commit Anyway") skips them.
const checked = !useCommit.getState().checkProblems.length;
if (checked) {
+18 -4
Переглянути файл
@@ -57,6 +57,14 @@ export function groupOf(fs: FileStatus): GroupId | null {
return "changes";
}
/**
* Added to the index, then deleted from disk: no change against HEAD, so the change list leaves
* it out, but the staging area shows the staged addition (and the deletion, unstaged).
*/
export function addedThenDeleted(fs: Pick<FileStatus, "staged" | "unstaged">): boolean {
return fs.staged === "added" && fs.unstaged === "deleted";
}
export function isPartiallyStaged(fs: FileStatus): boolean {
return (
!!fs.staged &&
@@ -99,7 +107,9 @@ const KIND_ORDER: GroupId[] = ["conflicts", "changes", "unversioned"];
function fileNode(fs: FileStatus, root: string, group: GroupId, flat: boolean, scope: string = group): ChangeNode {
const path = stripSlash(fs.path);
const rel = relTo(root, path);
const kind = effectiveKind(fs) ?? "modified";
// Under Staged / Unstaged, a file without an overall kind (added, then deleted) shows its side's.
const side = group === "staged" ? fs.staged : group === "unstaged" ? fs.unstaged : null;
const kind = effectiveKind(fs) ?? (side === "added" || side === "deleted" ? side : "modified");
const dir = dirName(rel);
return {
key: `${scope}:${path}`,
@@ -259,7 +269,7 @@ export function buildChangeTree(
const repoRoots = byRepo ? repos : [];
const byGroup = new Map<GroupId, FileStatus[]>();
for (const fs of status) {
const g = groupOf(fs);
const g = groupOf(fs) ?? (byStaging && addedThenDeleted(fs) ? "changes" : null);
if (!g) continue;
let list = byGroup.get(g);
if (!list) byGroup.set(g, (list = []));
@@ -400,8 +410,12 @@ export function planCommit(status: readonly FileStatus[], checks: ReadonlyMap<st
const plan: CommitPlan = { stage: [], exclude: [], included: [], partial: [] };
for (const fs of status) {
if (!groupOf(fs)) {
// Listed nowhere, yet staged: added to the index, then deleted from disk. It is no
// change against HEAD, so the commit must not pick up the staged addition.
// Added to the index, then deleted from disk: no change against HEAD, so the commit
// leaves the staged addition out, unless the staging area commits it (checked "staged").
if (addedThenDeleted(fs) && (checks.get(fs.path) ?? checks.get(stripSlash(fs.path))) === "staged") {
plan.included.push(fs);
continue;
}
if (fs.staged && fs.staged !== "conflicted" && fs.unstaged !== "ignored") plan.exclude.push(stripSlash(fs.path));
continue;
}
+3 -1
Переглянути файл
@@ -5,7 +5,7 @@
*/
import type { ChangelistState, FileStatus } from "@/bindings";
import { useWorkflowSettings, workflowSettings } from "@/platform/workflowSettings";
import { groupOf, type CheckState } from "./changes";
import { addedThenDeleted, groupOf, type CheckState } from "./changes";
import { withListDefaults } from "./changelists";
const enabled = (vcs: { git: { stagingArea: boolean }; commit: { nonModal: boolean } }) =>
@@ -31,6 +31,8 @@ export function stagingChecks(status: readonly FileStatus[]): Map<string, CheckS
const all = isCommitAll(status);
const out = new Map<string, CheckState>();
for (const f of status) {
// A staged addition deleted from disk is committed as staged (nothing against HEAD for Commit All).
if (addedThenDeleted(f) && !all) out.set(f.path, "staged");
if (groupOf(f) !== "changes") continue;
out.set(f.path, all ? "all" : staged(f) ? "staged" : "none");
}
+1
Переглянути файл
@@ -105,6 +105,7 @@
display: flex;
gap: 10px;
width: 340px;
max-width: 100%;
/* Never grow past the window: the close button must stay reachable. */
max-height: calc(100vh - 48px);
padding: 14px 34px 14px 14px;
+3
Переглянути файл
@@ -2,6 +2,8 @@
position: fixed;
/* Inside the editor island's bottom-right corner, clear of the right stripe. */
right: 78px;
/* A narrow window narrows the balloons instead of pushing them off its left edge. */
left: 16px;
bottom: calc(var(--h-statusbar) + 16px);
/* Balloons belong to the main window: modal dialogs cover them, like IDEA. */
z-index: calc(var(--z-dialog) - 1);
@@ -12,6 +14,7 @@
pointer-events: none;
}
.balloon {
max-width: 100%;
pointer-events: auto;
animation: slideIn var(--dur) var(--ease);
}