Compare commits

...
Author SHA1 Message Date
l0ng-ai 8fc6d8dda3 fix(editor): align the line separator menu 2026-11-23 07:48:02 +08:00
4 changed files with 52 additions and 6 deletions

No files matched your search

+36
View File
@@ -1,5 +1,41 @@
import { expect, openFromTree, test } from "./fixtures";
test("the line separator menu has a heading and keeps the current choice visible", async ({ workbench: page }) => {
await openFromTree(page, "build.gradle.kts");
const status = page.locator('[data-status-item="editor.lineEnding"]').getByRole("button");
const menu = page.getByRole("menu", { name: /^Line Separator$/i });
const windows = "Windows (\\r\\n)";
const unix = "Unix and macOS (\\n)";
const classic = "Classic Mac OS (\\r)";
await expect(status).toHaveText("LF");
await status.click();
const heading = menu.locator("..").getByText("Line Separator", { exact: true });
expect(await heading.count()).toBe(1);
await expect(heading).toHaveCSS("font-size", "13px");
await expect(menu.locator('[role^="menuitem"]')).toHaveText([windows, unix, classic]);
await page.setViewportSize({ width: 540, height: 540 });
await expect(heading).toBeInViewport({ ratio: 1 });
await expect(menu.getByRole("menuitemcheckbox", { name: unix, checked: true })).toBeInViewport({ ratio: 1 });
await expect(menu.getByRole("menuitem", { name: windows })).toBeFocused();
await page.keyboard.press("Enter");
await expect(status).toHaveText("CRLF");
await status.click();
await expect(menu.getByRole("menuitemcheckbox", { name: windows, checked: true })).toBeFocused();
await page.keyboard.press("ArrowDown");
await page.keyboard.press("Enter");
await expect(status).toHaveText("LF");
await page.evaluate(async () => {
const path = "/src/platform/i18n.ts";
await (await import(/* @vite-ignore */ path)).setLocale("zh");
});
await status.click();
const translated = page.getByRole("menu", { name: "行分隔符", exact: true });
await expect(translated.getByRole("menuitem", { name: "Windows 换行 (\\r\\n)", exact: true })).toBeVisible();
});
test("status bar uses its row height and widget insets in both densities", async ({ workbench: page }) => {
const editor = await openFromTree(page, "build.gradle.kts");
const bar = page.locator('footer[aria-label="Status bar"]');
+11 -6
View File
@@ -417,6 +417,11 @@ export function CaretStatus() {
}
const EOL_LABEL: Record<LineEnding, string> = { lf: "LF", crLf: "CRLF", cr: "CR" };
const EOL_CHOICES: { id: LineEnding; label: string }[] = [
{ id: "crLf", label: "Windows (\\r\\n)" },
{ id: "lf", label: "Unix and macOS (\\n)" },
{ id: "cr", label: "Classic Mac OS (\\r)" },
];
export function LineEndingStatus() {
const meta = useActiveMeta();
@@ -454,12 +459,12 @@ export function LineEndingStatus() {
onClose={() => setOpen(false)}
anchor={ref}
placement="top-end"
aria-label="Line separator"
items={(["lf", "crLf", "cr"] as LineEnding[]).map((le) => ({
id: le,
label: `${EOL_LABEL[le]} – ${le === "lf" ? "Unix and macOS (\\n)" : le === "crLf" ? "Windows (\\r\\n)" : "Classic Mac OS (\\r)"}`,
checked: meta.lineEnding === le ? true : undefined,
run: () => choose(le),
title="Line Separator"
items={EOL_CHOICES.map(({ id, label }) => ({
id,
label,
checked: meta.lineEnding === id ? true : undefined,
run: () => choose(id),
}))}
/>
</>
+4
View File
@@ -965,6 +965,10 @@
"Tag value": "Tag value",
"Attribute": "Attribute",
"Contents differ only in line separators": "Contents differ only in line separators",
"Line Separator": "Line Separator",
"Windows (\\r\\n)": "Windows (\\r\\n)",
"Unix and macOS (\\n)": "Unix and macOS (\\n)",
"Classic Mac OS (\\r)": "Classic Mac OS (\\r)",
"Cannot remove a worktree containing the open project.": "Cannot remove a worktree containing the open project.",
"Delete Remote Branches": "Delete Remote Branches",
"Delete the {length} branches '{names}' on the remote? The remote-tracking branches are removed as well.": "Delete the {length} branches '{names}' on the remote? The remote-tracking branches are removed as well.",
+1
View File
@@ -5141,6 +5141,7 @@
"Days on which files changed; older revisions are removed when a project opens.": "按文件有更改的天数计算;打开项目时会删除更早的修订。",
"Language of menus and dialogs; untranslated text stays in English.": "菜单和对话框的语言;未翻译的文本保持英文。",
"Unix and macOS (\\n)": "Unix 和 macOS (\\n)",
"Windows (\\r\\n)": "Windows 换行 (\\r\\n)",
"Classic Mac OS (\\r)": "经典 Mac OS (\\r)",
"Encoding of new files; decodes project files that are not valid UTF-8 and have no BOM.": "新文件的编码;也用于解码不是有效 UTF-8 且没有 BOM 的项目文件。",
"Stored in the IDE; used by projects without their own scheme.": "存储在 IDE 中;供没有自己方案的项目使用。",