diff --git a/e2e/codeInsight.spec.ts b/e2e/codeInsight.spec.ts index 0e58e0037..0f94d16bf 100644 --- a/e2e/codeInsight.spec.ts +++ b/e2e/codeInsight.spec.ts @@ -73,6 +73,13 @@ test("completion lists the server's items and inserts the chosen one", async ({ await expect(method.locator(".cm-lsp-type")).toHaveText("OrderDto"); 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. + const footerBelowList = await popup.evaluate((t) => { + const list = t.querySelector(":scope > ul")!; + const footer = t.querySelector(":scope > .cm-lsp-completion-footer")!; + return footer.getBoundingClientRect().top >= list.getBoundingClientRect().bottom - 1; + }); + expect(footerBelowList).toBe(true); await page.keyboard.press("Enter"); await expect(popup).toBeHidden(); await expect(editor.locator(".cm-activeLine")).toHaveText(/^\s*order\.toDto\(\)$/); diff --git a/src/editor/lsp/completion.test.ts b/src/editor/lsp/completion.test.ts index 42f135809..ea019a944 100644 --- a/src/editor/lsp/completion.test.ts +++ b/src/editor/lsp/completion.test.ts @@ -602,6 +602,45 @@ describe("explicit completion", () => { }); }); +describe("completion footer", () => { + let view: EditorView | null = null; + afterEach(() => { + view?.destroy(); + view = null; + }); + + it("stays below the list after CodeMirror rebuilds the options", async () => { + const source: CompletionSource = (ctx) => ({ + from: ctx.pos, + options: [{ label: "println" }, { label: "print" }], + }); + view = new EditorView({ + state: EditorState.create({ + doc: "pri", + selection: { anchor: 3 }, + extensions: [completionExtension(), EditorState.languageData.of(() => [{ openideaCompletion: source }])], + }), + parent: document.body, + }); + startCompletion(view); + await vi.waitFor(() => + expect(document.querySelector(".cm-tooltip-autocomplete > .cm-lsp-completion-footer")).not.toBeNull(), + ); + const tooltip = document.querySelector(".cm-tooltip-autocomplete")!; + const footer = tooltip.querySelector(":scope > .cm-lsp-completion-footer")!; + expect(footer.previousElementSibling?.tagName).toBe("UL"); + + // CodeMirror removes the