diff --git a/e2e/codeInsight.spec.ts b/e2e/codeInsight.spec.ts index f27f1c1f9..c5f65fac4 100644 --- a/e2e/codeInsight.spec.ts +++ b/e2e/codeInsight.spec.ts @@ -111,6 +111,7 @@ test("completion lists the server's items and inserts the chosen one", async ({ }); await expect(editor.locator(".cm-content")).toHaveCSS("font-size", zoomedSize); await expect(method.locator(".cm-completionLabel")).toHaveCSS("font-size", zoomedSize); + await page.keyboard.type("toD"); await expect(popup.getByText("total", { exact: true })).toBeHidden(); // Refreshing the results rebuilds the list; the hint bar must stay below it, not jump to the top. @@ -124,6 +125,37 @@ test("completion lists the server's items and inserts the chosen one", async ({ await expect(popup).toBeHidden(); await expect(editor.locator(".cm-activeLine")).toHaveText(/^\s*order\.toDto\(\)$/); expect((await ipcCalls(page, "lsp_completion")).length).toBeGreaterThan(0); + + await page.evaluate(async () => { + const path = "/src/platform/actions.ts"; + await (await import(/* @vite-ignore */ path)).executeAction("editor.splitRight"); + }); + const panes = page.locator("[data-pane-id]"); + await expect(panes).toHaveCount(2); + await page.setViewportSize({ width: 480, height: 760 }); + await panes.last().locator(".cm-content").focus(); + await page.keyboard.press("End"); + await page.keyboard.press("Enter"); + await page.keyboard.type("order."); + await page.keyboard.press("Control+Space"); + const footer = popup.locator(".cm-lsp-completion-footer"); + await expect + .poll(() => + footer.evaluate((el) => { + const tip = el.querySelector("span")!; + const sort = el.querySelector("button")!; + const a = tip.getBoundingClientRect(); + const b = sort.getBoundingClientRect(); + return { + oneRow: Math.abs(a.y + a.height / 2 - b.y - b.height / 2) <= 1, + hintClipped: tip.scrollWidth > tip.clientWidth, + sortFits: sort.scrollWidth <= sort.clientWidth + 1 && b.right <= el.getBoundingClientRect().right, + }; + }), + ) + .toEqual({ oneRow: true, hintClipped: true, sortFits: true }); + await expect(footer.getByTitle("Press ↵ to insert, ⇥ to replace")).toHaveCSS("font-size", "12px"); + await expect(footer.getByRole("button", { name: "Sort by name" })).toBeInViewport({ ratio: 1 }); }); test("long completion signatures fit the editor when the workbench is narrowed", async ({ workbench: page }) => { diff --git a/src/editor/lsp/completion.ts b/src/editor/lsp/completion.ts index 71e4bd259..96be344fe 100644 --- a/src/editor/lsp/completion.ts +++ b/src/editor/lsp/completion.ts @@ -1045,6 +1045,7 @@ const completionPopup = ViewPlugin.fromClass( footer.className = "cm-lsp-completion-footer"; const tip = document.createElement("span"); tip.textContent = tx("Press ↵ to insert, ⇥ to replace"); + tip.title = tip.textContent; footer.append(tip, sortToggle(this.view)); } // CodeMirror appends a fresh list when the candidates change. diff --git a/src/editor/lsp/theme.ts b/src/editor/lsp/theme.ts index 6391bd3c6..015218248 100644 --- a/src/editor/lsp/theme.ts +++ b/src/editor/lsp/theme.ts @@ -212,22 +212,28 @@ export const lspTheme = EditorView.theme({ color: "var(--fg-muted)", }, ".cm-lsp-completion-footer, .cm-lsp-inplace-footer": { - display: "flex", flex: "none", - flexWrap: "wrap", alignItems: "center", - padding: "5px 12px", backgroundColor: "var(--bg-popup-inline, var(--bg-elev))", color: "var(--fg-subtle)", fontFamily: "var(--font-ui)", fontSize: "var(--fs-small)", - gap: "var(--space-1) var(--space-3)", - justifyContent: "space-between", borderRadius: "0 0 calc(var(--radius-popup) - 1px) calc(var(--radius-popup) - 1px)", }, + ".cm-lsp-completion-footer": { + display: "grid", + gridTemplateColumns: "minmax(0, 1fr) minmax(0, max-content)", + gap: "var(--space-2)", + paddingBlock: "var(--space-1) 3px", + paddingInline: "var(--space-3) var(--space-2)", + }, + ".cm-lsp-completion-footer > span, .cm-lsp-completion-sort": { + minWidth: "0", + overflow: "hidden", + textOverflow: "ellipsis", + whiteSpace: "nowrap", + }, ".cm-lsp-completion-sort": { - flex: "none", - maxWidth: "100%", padding: "0", border: "none", background: "none", @@ -490,7 +496,14 @@ export const lspTheme = EditorView.theme({ '.cm-lsp-inplace-suggestions button[aria-current="true"]': { backgroundColor: "var(--bg-list-selected, var(--bg-tree-selected, var(--bg-selected-strong)))", }, - ".cm-lsp-inplace-footer": { overflowWrap: "anywhere" }, + ".cm-lsp-inplace-footer": { + display: "flex", + flexWrap: "wrap", + padding: "5px 12px", + gap: "var(--space-1) var(--space-3)", + justifyContent: "space-between", + overflowWrap: "anywhere", + }, // --- floating lightbulb (intentions.ts) ----------------------------------- ".cm-lsp-bulb": {