fix(editor): compact the line-number gutter

Цей коміт міститься в:
l0ng-ai committed 2026-11-22 19:55:42 +08:00
1 джерело ce6c61aa5e
коміт eaec4430af
4 files changed
+52 -7

No files matched your search

+44
Переглянути файл
@@ -0,0 +1,44 @@
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`);
});
+2
Переглянути файл
@@ -89,6 +89,8 @@ test("Sticky Lines follows editor text, line numbers and the viewport below Find
expect(pinnedGutter!.width).toBeCloseTo(liveGutter!.width, 0);
expect(await codeStart(text)).toBeCloseTo(liveX, 0);
await expect(sticky).toHaveCSS("font-size", "16px");
await expect(sticky.locator(".cm-openidea-stickyNumber").first()).toHaveCSS("font-size", "15px");
await expect(editor.locator(".cm-lineNumbers .cm-gutterElement").first()).toHaveCSS("font-size", "15px");
await expect(sticky).toHaveCSS("tab-size", await content.evaluate((element) => getComputedStyle(element).tabSize));
await scroller.evaluate((element) => {
element.scrollLeft = 32;
+3 -2
Переглянути файл
@@ -255,8 +255,9 @@ export const openideaTheme = EditorView.theme({
userSelect: "none",
},
".cm-lineNumbers .cm-gutterElement, .cm-openidea-stickyNumber": {
minWidth: "32px",
padding: "0 8px 0 10px",
minWidth: "calc(max(16px, var(--openidea-editor-font-size, var(--fs-code))) + var(--space-2))",
paddingInline: "var(--space-1)",
fontSize: "max(1px, calc(var(--openidea-editor-font-size, var(--fs-code)) - 1px))",
textAlign: "right",
fontVariantNumeric: "tabular-nums",
},
+3 -5
Переглянути файл
@@ -1,7 +1,4 @@
/*
* Line-number gutter element class; the marker is a pseudo-element that, like
* IDEA, replaces the number (centred on the element's content box).
*/
/* The marker replaces the number and shares its trailing edge. */
.bp {
position: relative;
color: transparent !important;
@@ -10,8 +7,9 @@
.bp::before {
content: "";
position: absolute;
left: calc(50% + 1px);
left: calc(100% - var(--space-1) - 0.5em);
top: 50%;
font-size: var(--openidea-editor-font-size, var(--fs-code));
width: 1em;
height: 1em;
transform: translate(-50%, -50%);