дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-11-23 18:10:45 +02:00
Editor line numbers use a font 1 px smaller than the code and a more compact column. The gutter grows with the editor font and with longer line numbers. Sticky Lines uses the same number metrics, and a breakpoint sits at the trailing edge of the number column at the full editor font size.
45 рядки
2.1 KiB
TypeScript
45 рядки
2.1 KiB
TypeScript
import { expect, test } from "./fixtures";
|
|
|
|
test("line numbers stay smaller than the code and leave room for a breakpoint", async ({ workbench: page }) => {
|
|
await page.evaluate(async () => {
|
|
const backendPath = "/src/editor/core/backend.ts";
|
|
const servicesPath = "/src/workbench/contributions.ts";
|
|
const { docBackend } = await import(/* @vite-ignore */ backendPath);
|
|
const { editorService } = await import(/* @vite-ignore */ servicesPath);
|
|
const path = "/dev/acme-api/queue.ts";
|
|
docBackend().files.set(path, ["const queue = [1, 2, 3];", "queue.push(4);", "console.log(queue);"].join("\n"));
|
|
await editorService().openFile(path);
|
|
});
|
|
const editor = page.locator('.cm-editor[data-language="TypeScript"]');
|
|
const content = editor.locator(".cm-content");
|
|
const number = editor.locator(".cm-lineNumbers").getByText("2", { exact: true });
|
|
await expect(number).toBeVisible();
|
|
const size = await content.evaluate((element) => Number.parseFloat(getComputedStyle(element).fontSize));
|
|
await expect(number).toHaveCSS("font-size", `${size - 1}px`);
|
|
await expect(number).toHaveCSS("padding-inline-start", "4px");
|
|
await expect(number).toHaveCSS("padding-inline-end", "4px");
|
|
const column = editor.locator(".cm-lineNumbers");
|
|
expect((await column.boundingBox())!.width).toBeCloseTo(24, 0);
|
|
|
|
await number.click();
|
|
const markerSize = () => number.evaluate((element) => getComputedStyle(element, "::before").width);
|
|
await expect.poll(markerSize).toBe(`${size}px`);
|
|
await expect
|
|
.poll(() =>
|
|
number.evaluate((element) => {
|
|
const marker = getComputedStyle(element, "::before");
|
|
return element.clientWidth - Number.parseFloat(marker.left) - Number.parseFloat(marker.width) / 2;
|
|
}),
|
|
)
|
|
.toBeCloseTo(4, 0);
|
|
|
|
await content.press("Alt+Shift+.");
|
|
await expect(content).toHaveCSS("font-size", `${size + 1}px`);
|
|
await expect(number).toHaveCSS("font-size", `${size}px`);
|
|
await expect(number).toHaveCSS(
|
|
"line-height",
|
|
await content.evaluate((element) => getComputedStyle(element).lineHeight),
|
|
);
|
|
await expect.poll(markerSize).toBe(`${size + 1}px`);
|
|
});
|