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

...
Автор SHA1 Повідомлення Дата
l0ng-ai 88572f2ec1 Merge remote-tracking branch 'origin/main' into ux/local-history-layout 2026-11-20 07:12:38 +08:00
l0ng-ai 1a2adab237 fix(editor): align Reformat Code dialog groups and controls (#4611)
The Reformat Code dialog's option groups and controls were laid out ad hoc, so labels and checkboxes misaligned and the scope group wrapped awkwardly. The dialog now uses shared dialog fieldsets with aligned groups and controls, the same as the other analysis dialogs.
2026-11-20 07:12:25 +08:00
l0ng-ai 9ed87d77a7 fix(project-tree): make the Move dialog readable in narrow windows (#4609)
The Move dialog's title, target field and validation were laid out for a wide window, so in narrow ones the path and Browse button were clipped. The dialog now names what it moves (file, directory or N items), the target row wraps with its Browse button, and invalid targets (a folder into itself, the same directory) are explained inline.
2026-11-20 06:55:23 +08:00
l0ng-ai 204a078432 fix(vcs): scope the new styles to Local History 2026-11-20 05:31:58 +08:00
l0ng-ai ef051d9e31 fix(vcs): give Local History diffs room in narrow panes 2026-11-20 05:23:39 +08:00
15 змінених файлів з 548 додано та 180 видалено

No files matched your search

+86
Переглянути файл
@@ -0,0 +1,86 @@
import { expect, ipcCalls, stubDesktop, test } from "./fixtures";
const root = "/dev/acme-api";
const name = `InternationalSettlement${"Reconciliation".repeat(10)}.txt`;
const destination = `archive/Approved${"Settlement".repeat(11)}`;
test("keeps a long source name and destination readable while moving a file", async ({ workbench: page }) => {
await page.evaluate(
async ({ root, name, destination }) => {
const fsModule = "/src/features/project-tree/fs.ts";
const { projectFs } = await import(/* @vite-ignore */ fsModule);
const storeModule = "/src/features/project-tree/store.ts";
const { loadDir } = await import(/* @vite-ignore */ storeModule);
const fs = projectFs(root);
await fs.createFile(`${root}/${name}`);
await fs.createDir(`${root}/archive`);
await fs.createDir(`${root}/${destination}`);
await loadDir(root, true);
},
{ root, name, destination },
);
await page.getByRole("treeitem", { name, exact: true }).click();
await page.keyboard.press("F6");
const dialog = page.getByRole("dialog", { name: "Move", exact: true });
const field = dialog.getByRole("textbox", { name: "Target directory" });
await expect(field).toBeFocused();
await page.setViewportSize({ width: 470, height: 480 });
await expect
.poll(() => dialog.locator("[data-dialog-body]").evaluate((el) => el.scrollWidth - el.clientWidth))
.toBeLessThanOrEqual(1);
expect(
await field.evaluate((el: HTMLInputElement) => el.value.slice(el.selectionStart ?? 0, el.selectionEnd ?? 0)),
).toBe("acme-api");
const submit = dialog.getByRole("button", { name: "Refactor", exact: true });
await expect(submit).toBeDisabled();
await field.fill(destination);
await expect(dialog.getByText(destination, { exact: true })).toBeVisible();
await expect(submit).toBeInViewport({ ratio: 1 });
await dialog.getByRole("checkbox", { name: "Search for references" }).uncheck();
await dialog.getByRole("checkbox", { name: "Search in comments and strings" }).uncheck();
await submit.click();
await expect(dialog).toBeHidden();
await expect
.poll(() =>
page.evaluate(
async ({ root, destination }) => {
const fsModule = "/src/features/project-tree/fs.ts";
const { projectFs } = await import(/* @vite-ignore */ fsModule);
return (await projectFs(root).readDir(`${root}/${destination}`)).map((entry: { name: string }) => entry.name);
},
{ root, destination },
),
)
.toEqual([name]);
});
test("browses for a destination and keeps the current path on cancel", async ({ workbench: page }) => {
await page.getByRole("treeitem", { name: "README.md", exact: true }).click();
await stubDesktop(page);
await page.evaluate(() => {
window.__ipc.handlers.file_dialog_needs_gtk = () => false;
let chosen: string | null = null;
window.__ipc.handlers["plugin:dialog|open"] = () => {
const result = chosen;
chosen = "C:\\Projects\\Invoice Archive";
return result;
};
});
await page.keyboard.press("F6");
const dialog = page.getByRole("dialog", { name: "Move", exact: true });
const field = dialog.getByRole("textbox", { name: "Target directory" });
const browse = dialog.getByRole("button", { name: "Browse for target directory", exact: true });
await browse.click();
await expect.poll(() => ipcCalls(page, "plugin:dialog|open")).toHaveLength(1);
await expect(field).toHaveValue(root);
await browse.click();
await expect(field).toHaveValue("C:/Projects/Invoice Archive");
await expect(dialog.getByRole("button", { name: "Refactor", exact: true })).toBeEnabled();
await field.fill("C:/");
await expect(dialog.getByText("C:/", { exact: true })).toBeVisible();
await field.fill("/");
await expect(dialog.getByText("/", { exact: true })).toBeVisible();
await page.keyboard.press("Escape");
await expect(dialog).toBeHidden();
});
+50
Переглянути файл
@@ -0,0 +1,50 @@
import { expect, ipcCalls, openFromTree, stubDesktop, test } from "./fixtures";
test("Local History gives the diff room and keeps revision selection across layouts", async ({ workbench: page }) => {
await page.setViewportSize({ width: 1180, height: 700 });
await openFromTree(page, "build.gradle.kts");
await stubDesktop(page);
await page.evaluate(async () => {
const file = "/dev/acme-api/build.gradle.kts";
const entries = [
{ id: "after", path: file, timestampMs: 2000, label: "Saved", size: 31, kind: "snapshot" },
{ id: "before", path: file, timestampMs: 1000, label: "Original", size: 34, kind: "snapshot" },
];
window.__ipc.handlers.history_list_dir = () => ({ entries, deleted: [] });
window.__ipc.handlers.history_content = ({ id }) =>
id === "before" ? 'val reportMode = "summary"\n' : 'val reportMode = "detailed"\n';
window.__ipc.handlers.vcs_file_mode = () => null;
window.__ipc.handlers.fs_probe = () => ({ size: 32, binary: false, tooLarge: false });
const actionsModule = "/src/platform/actions.ts";
const { executeAction } = await import(/* @vite-ignore */ actionsModule);
await executeAction("vcs.localHistory", file);
});
const revisions = page.getByRole("listbox", { name: "Revisions" });
await expect(revisions.getByRole("option", { name: /Saved/ })).toBeVisible();
const separator = page.getByRole("separator", { name: "Revisions" });
await expect(separator).toHaveAttribute("aria-orientation", "vertical");
const initialWidth = (await revisions.boundingBox())!.width;
await separator.press("ArrowLeft");
await expect.poll(async () => (await revisions.boundingBox())!.width).toBeLessThan(initialWidth);
const original = revisions.getByRole("option", { name: /^Original/ });
await original.click();
await expect(original).toHaveAttribute("aria-selected", "true");
await expect.poll(async () => ipcCalls(page, "history_content")).toContainEqual({ id: "before" });
await page.setViewportSize({ width: 480, height: 620 });
await expect(separator).toHaveAttribute("aria-orientation", "horizontal");
await expect(original).toHaveAttribute("aria-selected", "true");
const diff = page.locator(".cm-mergeView").filter({ hasText: "summary" });
await expect(diff).toBeVisible();
const listBox = (await revisions.boundingBox())!;
const diffBox = (await diff.boundingBox())!;
expect(diffBox.y).toBeGreaterThanOrEqual(listBox.y + listBox.height);
expect(diffBox.width).toBeGreaterThanOrEqual(listBox.width - 2);
await page.setViewportSize({ width: 1180, height: 700 });
await expect(separator).toHaveAttribute("aria-orientation", "vertical");
await expect(original).toHaveAttribute("aria-selected", "true");
});
+55
Переглянути файл
@@ -0,0 +1,55 @@
import { expect, openFromTree, test } from "./fixtures";
test("Reformat File aligns scope and option controls and supports arrow-key scope changes", async ({
workbench: page,
}) => {
const editor = await openFromTree(page, "build.gradle.kts");
await editor.locator(".cm-line").first().click();
await page.keyboard.press("Home");
await page.keyboard.press("Shift+End");
await page.evaluate(async () => {
const path = "/src/platform/actions.ts";
const { executeAction } = await import(/* @vite-ignore */ path);
await executeAction("code.reformatDialog");
});
const dialog = page.getByRole("dialog", { name: /Reformat File/ });
const scope = dialog.getByRole("group", { name: "Scope" });
const selected = scope.getByRole("radio", { name: "Selected text" });
await expect(selected).toBeChecked();
await expect(scope.getByRole("radio").first()).toHaveAccessibleName("Selected text");
await selected.press("ArrowDown");
await expect(scope.getByRole("radio", { name: "Whole file" })).toBeChecked();
const optimize = dialog.getByRole("group", { name: "Options" }).getByRole("checkbox", { name: "Optimize imports" });
expect((await selected.boundingBox())!.x).toBeCloseTo((await optimize.boundingBox())!.x, 0);
await page.keyboard.press("Escape");
await expect(dialog).toBeHidden();
});
test("Reformat Code keeps long targets and the file mask usable in a narrow window", async ({ workbench: page }) => {
await page.setViewportSize({ width: 340, height: 460 });
const target = "InternationalSettlementReconciliation".repeat(4);
await page.evaluate(async (target) => {
const path = "/src/platform/actions.ts";
const { executeAction } = await import(/* @vite-ignore */ path);
await executeAction("code.reformatFiles", { directories: [`/dev/acme-api/${target}`] });
}, target);
const dialog = page.getByRole("dialog", { name: "Reformat Code", exact: true });
await expect(dialog.getByText(target, { exact: true })).toBeVisible();
const body = dialog.locator("[data-dialog-body]");
expect(await body.evaluate((el) => el.scrollWidth)).toBe(await body.evaluate((el) => el.clientWidth));
await expect(
dialog.getByRole("group", { name: "Options" }).getByRole("checkbox", { name: "Include subdirectories" }),
).toBeChecked();
const filters = dialog.getByRole("group", { name: "Filters" });
const mask = filters.getByRole("textbox", { name: "File mask" });
await expect(mask).toBeDisabled();
await filters.getByText("File mask:", { exact: true }).click();
await mask.fill("*.java");
await expect(mask).toHaveValue("*.java");
await dialog.getByRole("button", { name: "Cancel" }).click();
await expect(dialog).toBeHidden();
});
-27
Переглянути файл
@@ -553,33 +553,6 @@
}
/* Dialog bodies get no padding of their own; wrap the groups like Analysis dialogs' .form. */
.reformatBody {
display: flex;
flex-direction: column;
gap: 10px;
padding: 14px;
}
.reformatGroup {
margin: 0;
padding: 0;
border: 0;
display: flex;
flex-direction: column;
gap: var(--space-1-5);
}
.reformatLegend {
margin-bottom: 6px;
padding: 0;
font-size: var(--fs-small);
color: var(--fg-subtle);
}
.reformatOption {
display: flex;
align-items: center;
gap: var(--space-1-5);
font-size: var(--fs-ui);
}
.pasteImports {
display: flex;
flex-direction: column;
+6 -6
Переглянути файл
@@ -1,5 +1,5 @@
import { afterEach, describe, expect, it, vi } from "vitest";
import { act, fireEvent, render, screen } from "@testing-library/react";
import { act, fireEvent, render, screen, within } from "@testing-library/react";
import type { Location } from "@/bindings";
const openFile = vi.fn(async () => undefined);
@@ -19,7 +19,6 @@ const { closePopup, openPopup, useLspPopup } = await import("./popupStore");
const { useDocWindow, hoverDoc, pushHistory, stepHistory, hoverCandidates } = await import("./docs");
const { mountHoverDoc } = await import("./DocView");
const { hoverSource } = await import("./hover");
import popupStyles from "./Popups.module.css";
import { registerImportsOnPasteActions } from "./importsOnPaste";
import { EditorState } from "@codemirror/state";
import { EditorView } from "@codemirror/view";
@@ -352,7 +351,7 @@ describe("quick definition popup", () => {
});
describe("reformat dialog", () => {
it("wraps its content in the padded body", () => {
it("offers only whole-file formatting when the editor has no selection", () => {
const onRun = vi.fn();
openPopup({
kind: "reformat",
@@ -363,9 +362,10 @@ describe("reformat dialog", () => {
onRun,
});
render(<LspPopups />);
const body = screen.getByRole("dialog", { name: "Reformat File" }).querySelector("[data-dialog-body]")!;
expect(body.firstElementChild).toHaveClass(popupStyles.reformatBody!);
expect(body.firstElementChild!.querySelectorAll("fieldset")).toHaveLength(2);
const scope = within(screen.getByRole("group", { name: "Scope" }));
expect(scope.getByRole("radio", { name: "Selected text" })).toBeDisabled();
expect(scope.getByRole("radio", { name: "Whole file" })).toBeChecked();
expect(within(screen.getByRole("group", { name: "Options" })).getByRole("checkbox")).not.toBeChecked();
fireEvent.click(screen.getByRole("button", { name: "Run" }));
expect(onRun).toHaveBeenCalledWith({ selectionOnly: false, optimizeImports: false });
});
+21 -25
Переглянути файл
@@ -11,6 +11,7 @@ import {
List,
MenuList,
Popup,
Radio,
Select,
Spinner,
SymbolBadge,
@@ -35,6 +36,7 @@ import { renderCode } from "./markdown";
import { describeSummary } from "./workspaceEdit";
import { useUsagesStatus } from "./navigation";
import styles from "./Popups.module.css";
import fieldsetStyles from "@/ui/DialogFieldset.module.css";
import { tx } from "@/platform/i18n";
import { executeAction } from "@/platform/actions";
@@ -681,7 +683,7 @@ function ReformatDialog({ popup }: { popup: Extract<LspPopup, { kind: "reformat"
open
onClose={closePopup}
title={popup.title}
width={380}
width={400}
buttons={[
{
label: "Run",
@@ -695,33 +697,27 @@ function ReformatDialog({ popup }: { popup: Extract<LspPopup, { kind: "reformat"
{ label: "Cancel", role: "cancel" },
]}
>
<div className={styles.reformatBody}>
<fieldset className={styles.reformatGroup}>
<legend className={styles.reformatLegend}>
<div className={fieldsetStyles.body}>
<fieldset className={fieldsetStyles.group}>
<legend className={fieldsetStyles.legend}>
<T>Scope</T>
</legend>
<label className={styles.reformatOption}>
<input
type="radio"
name="reformat-scope"
checked={!selectionOnly}
onChange={() => setSelectionOnly(false)}
/>
<T>Whole file</T>
</label>
<label className={clsx(styles.reformatOption, !popup.hasSelection && styles.disabled)}>
<input
type="radio"
name="reformat-scope"
checked={selectionOnly}
disabled={!popup.hasSelection}
onChange={() => setSelectionOnly(true)}
/>
<T>Selected text</T>
</label>
<Radio
name="reformat-scope"
checked={selectionOnly}
disabled={!popup.hasSelection}
onChange={() => setSelectionOnly(true)}
label="Selected text"
/>
<Radio
name="reformat-scope"
checked={!selectionOnly}
onChange={() => setSelectionOnly(false)}
label="Whole file"
/>
</fieldset>
<fieldset className={styles.reformatGroup}>
<legend className={styles.reformatLegend}>
<fieldset className={fieldsetStyles.group}>
<legend className={fieldsetStyles.legend}>
<T>Options</T>
</legend>
<Checkbox
+15
Переглянути файл
@@ -199,6 +199,21 @@
align-items: center;
gap: var(--space-2);
}
.reformatSubject {
overflow-wrap: anywhere;
font-size: var(--fs-ui);
font-weight: 600;
}
.reformatMask {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: var(--space-2);
}
.reformatMaskInput {
flex: 1 1 12ch;
min-width: 0;
}
.languageSelect {
min-width: 180px;
}
+41 -30
Переглянути файл
@@ -29,6 +29,7 @@ import {
type StructuralForm,
} from "./structural";
import styles from "./Analysis.module.css";
import fieldsetStyles from "@/ui/DialogFieldset.module.css";
import { tx } from "@/platform/i18n";
import { notifications } from "@/workbench/contributions";
@@ -168,40 +169,50 @@ function ReformatCodeDialog({ targets, onClose }: { targets: readonly ReformatTa
{ label: "Cancel", role: "cancel" },
]}
>
<div className={styles.form}>
<div className={styles.hint}>{subject}</div>
{targets.some((t) => t.dir) && (
<div className={fieldsetStyles.body}>
<div className={styles.reformatSubject}>{subject}</div>
<fieldset className={fieldsetStyles.group}>
<legend className={fieldsetStyles.legend}>
<T>Options</T>
</legend>
<Checkbox
checked={options.recursive}
onChange={(recursive) => setOptions({ ...options, recursive })}
label="Include subdirectories"
checked={options.optimizeImports}
onChange={(optimizeImports) => setOptions({ ...options, optimizeImports })}
label="Optimize imports"
/>
)}
<Checkbox
checked={options.optimizeImports}
onChange={(optimizeImports) => setOptions({ ...options, optimizeImports })}
label="Optimize imports"
/>
<Checkbox
checked={options.changedTextOnly}
onChange={(changedTextOnly) => setOptions({ ...options, changedTextOnly })}
label="Only VCS changed text"
/>
<div className={styles.fieldRow}>
<Checkbox
checked={options.useMask}
onChange={(useMask) => setOptions({ ...options, useMask })}
label="File mask:"
checked={options.changedTextOnly}
onChange={(changedTextOnly) => setOptions({ ...options, changedTextOnly })}
label="Only VCS changed text"
/>
<Input
className={styles.grow}
value={options.mask}
disabled={!options.useMask}
placeholder="*.sh, *.py"
onChange={(e) => setOptions({ ...options, mask: e.target.value })}
aria-label="File mask"
/>
</div>
{targets.some((t) => t.dir) && (
<Checkbox
checked={options.recursive}
onChange={(recursive) => setOptions({ ...options, recursive })}
label="Include subdirectories"
/>
)}
</fieldset>
<fieldset className={fieldsetStyles.group}>
<legend className={fieldsetStyles.legend}>
<T>Filters</T>
</legend>
<div className={styles.reformatMask}>
<Checkbox
checked={options.useMask}
onChange={(useMask) => setOptions({ ...options, useMask })}
label="File mask:"
/>
<Input
className={styles.reformatMaskInput}
value={options.mask}
disabled={!options.useMask}
placeholder="*.sh, *.py"
onChange={(e) => setOptions({ ...options, mask: e.target.value })}
aria-label="File mask"
/>
</div>
</fieldset>
<div className={styles.hint}>
<T>Files are reformatted by their language's formatter and saved; files without one are skipped.</T>
</div>
+54
Переглянути файл
@@ -10,6 +10,60 @@
font-size: var(--fs-ui);
}
.moveForm {
display: flex;
flex-direction: column;
gap: var(--space-3);
padding: var(--space-3) var(--space-4);
}
.moveSubject {
color: var(--fg-emphasis);
font-size: var(--fs-ui);
font-weight: 600;
overflow-wrap: anywhere;
}
.moveDestination {
display: flex;
flex-wrap: wrap;
align-items: flex-start;
gap: var(--space-1) var(--space-2);
}
.moveDestination > .fieldLabel {
line-height: var(--h-field);
}
.moveControls {
display: flex;
flex: 1 1 244px;
flex-direction: column;
gap: var(--space-2);
min-width: 0;
}
.moveField {
display: flex;
align-items: center;
gap: var(--space-1);
}
.moveField input {
flex: 1 1 0;
}
.moveField button {
flex: none;
}
.movePath {
color: var(--fg-subtle);
font-size: var(--fs-small);
font-family: var(--font-mono);
overflow-wrap: anywhere;
}
.fieldLabel {
color: var(--fg);
font-size: var(--fs-ui);
+87 -35
Переглянути файл
@@ -6,7 +6,10 @@
import { useEffect, useRef, useState } from "react";
import { create } from "zustand";
import type { FileMove } from "@/bindings";
import { Checkbox, Dialog, Input, Spinner, T } from "@/ui";
import { Checkbox, Dialog, IconButton, Input, Spinner, T } from "@/ui";
import { choosePath } from "@/platform/choosePath";
import { isTauri } from "@/platform/ipc";
import { ipcPath } from "@/platform/paths";
import { runFileRefactoring, type FileRefactorOptions } from "./fileRefactor";
import {
isSameOrInside,
@@ -253,31 +256,59 @@ function RenameDialog({ request }: { request: Extract<FileRefactorRequest, { kin
/** Folder `typed` (absolute, or relative to the project root). */
function resolveTarget(typed: string, root: string): string {
const t = typed.trim().replace(/\/+$/, "");
if (!t) return root;
return t.startsWith("/") || /^[A-Za-z]:[\\/]/.test(t) ? t : joinPath(root, t);
const value = ipcPath(typed.trim());
if (!value) return root;
const absolute = value.startsWith("/") || /^[A-Za-z]:\//.test(value);
const isRoot = /^(?:[A-Za-z]:)?\/+$/.test(value);
const path = value.replace(/\/+$/, isRoot ? "/" : "");
return absolute ? path : joinPath(root, path);
}
function MoveDialog({ request }: { request: Extract<FileRefactorRequest, { kind: "move" }> }) {
const root = useProjectTree((s) => s.root) ?? "";
const [target, setTarget] = useState(request.target);
const [options, setOptions] = useState(() => loadOptions("move"));
const [browsing, setBrowsing] = useState(false);
const [browseError, setBrowseError] = useState<string | null>(null);
const field = useRef<HTMLInputElement>(null);
const { busy, run, cancel } = useSearch();
useEffect(() => {
const input = field.current;
const path = request.target.replace(/[\\/]+$/, "");
if (!input || !path || /^[A-Za-z]:$/.test(path)) return;
const start = Math.max(path.lastIndexOf("/"), path.lastIndexOf("\\")) + 1;
input.setSelectionRange(start, path.length);
input.scrollLeft = input.scrollWidth;
}, [request.target]);
const dest = resolveTarget(target, root);
const moves: FileMove[] = request.paths
.filter((p) => parentOf(p) !== dest)
.map((p) => ({ from: p, to: joinPath(dest, nameOf(p)) }));
.map((from) => ({ from, to: joinPath(dest, nameOf(from)) }))
.filter((move) => move.from !== move.to);
const error = request.paths.some((p) => isSameOrInside(dest, p))
? "Cannot move a folder into itself"
? tx("Cannot move a folder into itself")
: !moves.length
? "Already in this directory"
? tx("Already in this directory")
: null;
const subject =
request.paths.length === 1
? `Move ${request.dir || useProjectTree.getState().listings.has(request.paths[0]!) ? "directory" : "file"} '${nameOf(request.paths[0]!)}'`
: `Move ${request.paths.length} items`;
const single = request.paths.length === 1 ? request.paths[0]! : null;
const subject = single
? request.dir || useProjectTree.getState().listings.has(single)
? tx`Move directory '${nameOf(single)}'`
: tx`Move file '${nameOf(single)}'`
: tx`Move ${request.paths.length} items`;
const browse = async () => {
setBrowsing(true);
setBrowseError(null);
try {
const picked = await choosePath({ directory: true, title: tx("Select Target Directory"), defaultPath: dest });
if (picked !== null) setTarget(ipcPath(picked));
} catch (e) {
setBrowseError(e instanceof Error ? e.message : String(e));
} finally {
setBrowsing(false);
}
};
const submit = async () => {
if (busy || error) return;
if (busy || browsing || error) return;
saveOptions("move", options);
const status = await run(moves, options, "Move");
if (status !== "done") return;
@@ -291,38 +322,59 @@ function MoveDialog({ request }: { request: Extract<FileRefactorRequest, { kind:
width={520}
footerStart={busy ? <Busy /> : undefined}
buttons={[
{ label: "Refactor", role: "default", disabled: busy || !!error, onClick: () => void submit() },
{ label: "Refactor", role: "default", disabled: busy || browsing || !!error, onClick: () => void submit() },
{ label: "Cancel", role: "cancel", onClick: cancel },
]}
>
<form
className={styles.form}
className={styles.moveForm}
onSubmit={(e) => {
e.preventDefault();
void submit();
}}
>
<div className={styles.subject}>{subject}</div>
<label className={styles.fieldLabel} htmlFor="file-move-target">
<T>To directory:</T>
</label>
<Input
id="file-move-target"
autoFocus
mono
value={target}
disabled={busy}
invalid={!!error}
aria-label="Target directory"
onChange={(e) => setTarget(e.target.value)}
/>
<div className={styles.hint}>{relativeTo(root, dest) || (dest === root ? tx("Project root") : dest)}</div>
{error && (
<div className={styles.error} role="alert">
{error}
<div className={styles.moveSubject}>{subject}</div>
<div className={styles.moveDestination}>
<label className={styles.fieldLabel} htmlFor="file-move-target">
<T>To directory:</T>
</label>
<div className={styles.moveControls}>
<div className={styles.moveField}>
<Input
id="file-move-target"
ref={field}
data-autofocus
mono
value={target}
disabled={busy}
invalid={!!error}
aria-label="Target directory"
aria-describedby="file-move-preview"
onChange={(e) => {
setBrowseError(null);
setTarget(e.target.value);
}}
/>
{isTauri() && (
<IconButton
icon="folder-open"
title={tx("Browse for target directory")}
disabled={busy || browsing}
onClick={() => void browse()}
/>
)}
</div>
<div className={styles.movePath} id="file-move-preview" title={dest}>
{relativeTo(root, dest) || (dest === root ? tx("Project root") : dest)}
</div>
{(browseError ?? error) && (
<div className={styles.error} role="alert">
{browseError ?? error}
</div>
)}
<Options value={options} onChange={setOptions} move disabled={busy} />
</div>
)}
<Options value={options} onChange={setOptions} move disabled={busy} />
</div>
</form>
</Dialog>
);
+43 -32
Переглянути файл
@@ -5,6 +5,9 @@
display: flex;
background: var(--bg-app);
}
.resizable {
min-width: 0;
}
.sidebar {
flex: none;
width: 260px;
@@ -18,7 +21,7 @@
display: flex;
align-items: center;
gap: var(--space-2);
padding: 0 8px 0 12px;
padding: 0 var(--space-2) 0 var(--space-3);
border-bottom: 1px solid var(--border);
}
.title {
@@ -26,6 +29,14 @@
color: var(--fg-emphasis);
font-weight: 500;
}
.resizable .title {
min-width: 0;
font-size: var(--fs-ui);
font-weight: 600;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.list {
flex: 1;
}
@@ -35,14 +46,36 @@
min-width: 0;
gap: var(--space-0-5);
}
.time {
color: var(--fg-emphasis);
.resizable .entry {
width: 100%;
line-height: 1.2;
}
.label {
color: var(--fg-subtle);
font-size: var(--fs-small);
.primaryRow {
display: flex;
align-items: center;
gap: var(--space-1-5);
color: var(--fg-strong);
font-size: var(--fs-ui);
}
.primary,
.meta,
.path,
.deletedPath {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.meta,
.path,
.deletedPath {
color: var(--fg-muted);
font-size: var(--fs-small);
}
.meta {
font-variant-numeric: tabular-nums;
}
.deletedPath {
text-decoration: line-through;
}
.diff {
flex: 1;
@@ -51,33 +84,11 @@
flex-direction: column;
}
.message {
padding: 16px;
padding: var(--space-4);
color: var(--fg-faint);
text-align: center;
}
.path,
.deletedPath {
color: var(--fg);
font-size: var(--fs-small);
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.deletedPath {
color: var(--fg-muted);
text-decoration: line-through;
}
.labelRow {
display: flex;
align-items: center;
gap: var(--space-1);
min-width: 0;
color: var(--fg-muted);
}
.labelName {
font-size: var(--fs-small);
font-weight: 500;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
.resizable .message {
white-space: normal;
overflow-wrap: anywhere;
}
+49 -25
Переглянути файл
@@ -7,7 +7,7 @@ import { useCallback, useEffect, useRef, useState } from "react";
import type { HistoryEntry } from "@/bindings";
import { call, commands } from "@/platform/ipc";
import { relativePath, useProject } from "@/platform/project";
import { Button, Icon, List, Spinner, T } from "@/ui";
import { Button, Icon, List, Spinner, SplitGroup, SplitHandle, SplitPanel, T } from "@/ui";
import { notifications, type EditorInput } from "@/workbench/contributions";
import { DiffEditor } from "./DiffEditor";
import { confirmDialog } from "./dialogs";
@@ -70,6 +70,19 @@ export function LocalHistoryEditor({ input }: { input: EditorInput }) {
const anchor = useRef(0);
const previous = useRef(0);
const pointer = useRef(false);
const container = useRef<HTMLDivElement>(null);
const [stacked, setStacked] = useState(false);
useEffect(() => {
const el = container.current;
if (!el || typeof ResizeObserver === "undefined") return;
const observer = new ResizeObserver(([entry]) => {
const width = entry?.contentRect.width;
if (width) setStacked(width < 620);
});
observer.observe(el);
return () => observer.disconnect();
}, []);
const load = useCallback(() => {
call(commands.historyListDir(path))
@@ -197,9 +210,17 @@ export function LocalHistoryEditor({ input }: { input: EditorInput }) {
const revertLabel = current && !isLabel(current) && view?.deleted.has(current.path) ? "Restore" : "Revert";
return (
<div className={styles.root}>
<div
className={styles.sidebar}
<SplitGroup
elementRef={container}
className={`${styles.root} ${styles.resizable}`}
orientation={stacked ? "vertical" : "horizontal"}
storageKey="openidea.localHistory.layout"
>
<SplitPanel
id="revisions"
defaultSize="28%"
minSize={stacked ? "24%" : "160px"}
maxSize="52%"
onMouseDownCapture={(e) => {
pointer.current = e.button === 0 && !!(e.target as Element).closest('[role="option"]');
}}
@@ -253,7 +274,7 @@ export function LocalHistoryEditor({ input }: { input: EditorInput }) {
setExtra(new Set());
}
}}
rowHeight={view.folder ? 52 : 38}
rowHeight={view.folder ? 56 : 44}
aria-label="Revisions"
className={styles.list}
empty={
@@ -261,33 +282,36 @@ export function LocalHistoryEditor({ input }: { input: EditorInput }) {
{view.folder ? tx`No local history for this folder yet` : tx`No local history for this path yet`}
</span>
}
renderItem={(e) =>
isLabel(e) ? (
renderItem={(e) => {
const label = isLabel(e);
const pathText = !label && view.folder ? relativePath(root, e.path) || baseName(e.path) : null;
return (
<span className={styles.entry}>
<span className={styles.time}>{formatTime(e.timestampMs)}</span>
<span className={styles.labelRow}>
<Icon name="bookmark" size={12} />
<span className={styles.labelName}>{e.label}</span>
<span className={styles.primaryRow}>
{label && <Icon name="bookmark" size={12} />}
<span className={styles.primary} title={e.label}>
{e.label}
</span>
</span>
</span>
) : (
<span className={styles.entry}>
<span className={styles.time}>{formatTime(e.timestampMs)}</span>
{view.folder && (
<span className={view.deleted.has(e.path) ? styles.deletedPath : styles.path}>
{relativePath(root, e.path) || baseName(e.path)}
{pathText && (
<span className={view.deleted.has(e.path) ? styles.deletedPath : styles.path} title={pathText}>
{pathText}
</span>
)}
<span className={styles.label}>
{e.label} · {formatSize(e.size)}
<span className={styles.meta}>
{formatTime(e.timestampMs)}
{!label && ` · ${formatSize(e.size)}`}
</span>
</span>
)
}
);
}}
/>
)}
</div>
<div className={styles.diff}>{detail}</div>
</div>
</SplitPanel>
<SplitHandle aria-label={tx("Revisions")} />
<SplitPanel id="preview" defaultSize="72%">
{detail}
</SplitPanel>
</SplitGroup>
);
}
+9
Переглянути файл
@@ -2486,6 +2486,8 @@
"{length} selected items": "{length} selected items",
"Include subdirectories": "Include subdirectories",
"Only VCS changed text": "Only VCS changed text",
"Options": "Options",
"Filters": "Filters",
"Files are reformatted by their language's formatter and saved; files without one are skipped.": "Files are reformatted by their language's formatter and saved; files without one are skipped.",
"No changed files to reformat": "No changed files to reformat",
"No files to reformat": "No files to reformat",
@@ -2739,6 +2741,13 @@
"{description}; JVM options: {flags}": "{description}; JVM options: {flags}",
"Sorting Options": "Sorting Options",
"Sort by Duration": "Sort by Duration",
"Move file '{name}'": "Move file '{name}'",
"Move directory '{name}'": "Move directory '{name}'",
"Move {count} items": "Move {count} items",
"Browse for target directory": "Browse for target directory",
"Select Target Directory": "Select Target Directory",
"Cannot move a folder into itself": "Cannot move a folder into itself",
"Already in this directory": "Already in this directory",
"Resize left merge pane": "Resize left merge pane",
"Resize right merge pane": "Resize right merge pane",
"Database and schema": "Database and schema",
+8
Переглянути файл
@@ -8875,6 +8875,7 @@
"{length} selected items": "已选择 {length} 项",
"Include subdirectories": "包含子目录",
"Only VCS changed text": "仅 VCS 更改的文本",
"Filters": "筛选条件",
"Files are reformatted by their language's formatter and saved; files without one are skipped.": "文件由各自语言的格式化程序重新格式化并保存;没有格式化程序的文件将被跳过。",
"No changed files to reformat": "没有需要重新格式化的已更改文件",
"No files to reformat": "没有需要重新格式化的文件",
@@ -9109,6 +9110,13 @@
"{description}; JVM options: {flags}": "{description};JVM 选项:{flags}",
"Sorting Options": "排序选项",
"Sort by Duration": "按持续时间排序",
"Move file '{name}'": "移动文件「{name}」",
"Move directory '{name}'": "移动目录「{name}」",
"Move {count} items": "移动 {count} 个项目",
"Browse for target directory": "浏览目标目录",
"Select Target Directory": "选择目标目录",
"Cannot move a folder into itself": "不能将文件夹移动到自身目录中",
"Already in this directory": "已在此目录中",
"Resize left merge pane": "调整左侧合并窗格宽度",
"Resize right merge pane": "调整右侧合并窗格宽度",
"Database and schema": "数据库和 schema",
+24
Переглянути файл
@@ -0,0 +1,24 @@
.body {
display: flex;
flex-direction: column;
gap: var(--space-3);
padding: var(--space-4);
font-size: var(--fs-ui);
}
.group {
display: flex;
flex-direction: column;
gap: var(--space-2);
min-inline-size: 0;
margin: 0;
padding: var(--space-2) 0 0;
border: 0;
border-block-start: 1px solid var(--border-popup);
}
.legend {
padding: 0 var(--space-2) 0 0;
color: var(--fg-strong);
font-weight: 600;
}