mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-24 08:03:19 +00:00
fix(editor): align Parameter Info typography and overload rows (#4988)
Parameter Info uses the workbench font and UI size for its signatures. A single signature emphasizes the current argument in bold. Overload lists use inset separators and a rounded highlight for the active signature, while keeping the current argument visible as the list wraps.
This commit is contained in:
@@ -35,6 +35,7 @@ test("parameter info wraps long parameters and follows the editor width", async
|
||||
activeSignature: 0,
|
||||
activeParameter: 1,
|
||||
});
|
||||
await editor.locator(".cm-content").evaluate((el) => el.style.setProperty("font-size", "20px"));
|
||||
await page.setViewportSize({ width: 560, height: 650 });
|
||||
await expect
|
||||
.poll(async () => {
|
||||
@@ -44,8 +45,14 @@ test("parameter info wraps long parameters and follows the editor width", async
|
||||
.toBe(true);
|
||||
await expect.poll(() => popup.evaluate((el) => el.scrollWidth - el.clientWidth)).toBeLessThanOrEqual(1);
|
||||
await expect(popup.locator("b")).toHaveText(parameter);
|
||||
const fontSize = await editor.locator(".cm-content").evaluate((el) => getComputedStyle(el).fontSize);
|
||||
await expect(popup).toHaveCSS("font-size", fontSize);
|
||||
const ui = await page.locator("body").evaluate((el) => {
|
||||
const { fontFamily, fontSize } = getComputedStyle(el);
|
||||
return { fontFamily, fontSize };
|
||||
});
|
||||
await expect(popup).toHaveCSS("font-family", ui.fontFamily);
|
||||
await expect(popup).toHaveCSS("font-size", ui.fontSize);
|
||||
await expect(popup.locator(".cm-lsp-signature-active")).toHaveCSS("background-color", "rgba(0, 0, 0, 0)");
|
||||
await expect(popup.locator("b")).toHaveCSS("font-weight", "700");
|
||||
await page.keyboard.press("Escape");
|
||||
await expect(popup).toBeHidden();
|
||||
});
|
||||
@@ -55,8 +62,14 @@ test("parameter info keeps the active overload visible and scrolls to the others
|
||||
signature("formatInvoice", [`order: Cart${i}`, "currency: string"]),
|
||||
);
|
||||
const { popup } = await openParameterInfo(page, { signatures, activeSignature: 16, activeParameter: 1 });
|
||||
await expect(popup.locator(".cm-lsp-signature-row")).toHaveCount(signatures.length);
|
||||
const active = popup.locator(".cm-lsp-signature-active b");
|
||||
const rows = popup.locator(".cm-lsp-signature-row");
|
||||
await expect(rows).toHaveCount(signatures.length);
|
||||
const activeRow = popup.locator(".cm-lsp-signature-active");
|
||||
await expect(activeRow).toHaveAttribute("aria-current", "true");
|
||||
await expect(activeRow).not.toHaveCSS("background-color", "rgba(0, 0, 0, 0)");
|
||||
await expect.poll(() => rows.nth(1).evaluate((el) => getComputedStyle(el, "::before").borderTopWidth)).toBe("1px");
|
||||
await expect.poll(() => rows.first().evaluate((el) => getComputedStyle(el, "::before").content)).toBe("none");
|
||||
const active = activeRow.locator("b");
|
||||
await expect(active).toHaveText("currency: string");
|
||||
await expect
|
||||
.poll(async () => {
|
||||
|
||||
@@ -62,10 +62,11 @@ function signatureTooltip(s: SigState): Tooltip {
|
||||
above: true,
|
||||
strictSide: false,
|
||||
create: (view) => {
|
||||
const { signatures, activeSignature, activeParameter } = s.help;
|
||||
const dom = document.createElement("div");
|
||||
dom.className = "cm-lsp-signature";
|
||||
dom.classList.toggle("cm-lsp-signature-overloads", signatures.length > 1);
|
||||
dom.setAttribute("role", "tooltip");
|
||||
const { signatures, activeSignature, activeParameter } = s.help;
|
||||
let active: HTMLElement | null = null;
|
||||
signatures.forEach((sig, i) => {
|
||||
const row = document.createElement("div");
|
||||
@@ -94,13 +95,9 @@ function signatureTooltip(s: SigState): Tooltip {
|
||||
}
|
||||
const fit = ({ left, right }: { left: number; right: number }) => {
|
||||
const width = `${Math.max(0, Math.floor(right - left))}px`;
|
||||
const fontSize = getComputedStyle(view.contentDOM).fontSize;
|
||||
const changed = dom.style.getPropertyValue("--cm-signature-width") !== width || dom.style.fontSize !== fontSize;
|
||||
if (changed) {
|
||||
dom.style.setProperty("--cm-signature-width", width);
|
||||
dom.style.fontSize = fontSize;
|
||||
}
|
||||
return changed;
|
||||
if (dom.style.getPropertyValue("--cm-signature-width") === width) return false;
|
||||
dom.style.setProperty("--cm-signature-width", width);
|
||||
return true;
|
||||
};
|
||||
// Reveal the current parameter after wrapping or a vertical clamp. Leave manual scrolling alone.
|
||||
let fittedWidth = 0;
|
||||
|
||||
+22
-10
@@ -294,12 +294,12 @@ export const lspTheme = EditorView.theme({
|
||||
".cm-lsp-diag-shortcut": { color: "var(--fg-subtle)", fontSize: "var(--fs-small)", whiteSpace: "nowrap" },
|
||||
".cm-lsp-link-button:hover .cm-lsp-diag-action-label": { color: "var(--link-hover)", textDecoration: "underline" },
|
||||
".cm-tooltip.cm-lsp-signature": {
|
||||
fontFamily: "var(--openidea-editor-font, var(--font-mono))",
|
||||
fontWeight: "var(--fw-code, 400)",
|
||||
fontSize: "var(--openidea-editor-font-size, var(--fs-code))",
|
||||
fontFamily: "var(--font-ui)",
|
||||
fontWeight: "400",
|
||||
fontSize: "var(--fs-ui)",
|
||||
maxWidth: "min(640px, var(--cm-signature-width, 100%))",
|
||||
maxHeight: "min(380px, 65vh)",
|
||||
paddingBlock: "var(--space-0-5)",
|
||||
padding: "var(--space-1)",
|
||||
overflow: "auto",
|
||||
overscrollBehavior: "contain",
|
||||
},
|
||||
@@ -307,17 +307,29 @@ export const lspTheme = EditorView.theme({
|
||||
color: "var(--fg-secondary)",
|
||||
whiteSpace: "pre-wrap",
|
||||
overflowWrap: "anywhere",
|
||||
lineHeight: "1.5",
|
||||
padding: "var(--space-0-5) var(--space-2)",
|
||||
lineHeight: "1.4",
|
||||
padding: "var(--space-1) var(--space-2)",
|
||||
paddingInlineStart: "calc(var(--space-2) + 2ch)",
|
||||
textIndent: "-2ch",
|
||||
},
|
||||
".cm-lsp-signature-active": {
|
||||
color: "var(--fg-strong)",
|
||||
backgroundColor: "var(--bg-identifier-under-caret, color-mix(in srgb, var(--accent) 14%, transparent))",
|
||||
".cm-lsp-signature-active": { color: "var(--fg-strong)" },
|
||||
".cm-lsp-signature-overloads .cm-lsp-signature-row + .cm-lsp-signature-row": {
|
||||
position: "relative",
|
||||
marginBlockStart: "var(--space-1)",
|
||||
},
|
||||
".cm-lsp-signature-overloads .cm-lsp-signature-row + .cm-lsp-signature-row::before": {
|
||||
content: '""',
|
||||
position: "absolute",
|
||||
insetInline: "var(--space-2)",
|
||||
insetBlockStart: "calc(-1 * var(--space-0-5))",
|
||||
borderBlockStart: "1px solid var(--border-popup)",
|
||||
},
|
||||
".cm-lsp-signature-overloads .cm-lsp-signature-active": {
|
||||
backgroundColor: "var(--bg-tree-selected-inactive)",
|
||||
borderRadius: "var(--radius-selection)",
|
||||
},
|
||||
".cm-lsp-signature-disabled": { opacity: "0.55" },
|
||||
".cm-lsp-signature b": { fontWeight: "var(--fw-code-bold, 700)", color: "var(--fg-strong)" },
|
||||
".cm-lsp-signature b": { fontWeight: "700", color: "var(--fg-strong)" },
|
||||
".cm-lsp-signature-doc": {
|
||||
borderTop: "1px solid var(--border-popup)",
|
||||
marginTop: "var(--space-1)",
|
||||
|
||||
Reference in New Issue
Block a user