diff --git a/src/editor/lsp/hint.test.ts b/src/editor/lsp/hint.test.ts index e98461dc6..7397f7864 100644 --- a/src/editor/lsp/hint.test.ts +++ b/src/editor/lsp/hint.test.ts @@ -30,6 +30,7 @@ describe("pending hints", () => { vi.advanceTimersByTime(PENDING_HINT_DELAY_MS); expect(hint()).toBe("Waiting…"); expect(document.querySelector(".cm-lsp-hint")?.dataset.pending).toBe("true"); + expect(document.querySelector(".cm-lsp-hint .cm-lsp-hint-spinner svg")).not.toBeNull(); done(); expect(hint()).toBeNull(); }); @@ -37,6 +38,7 @@ describe("pending hints", () => { it("marks only progress as pending", () => { showHint(view, "Done"); expect(document.querySelector(".cm-lsp-hint")?.dataset.pending).toBeUndefined(); + expect(document.querySelector(".cm-lsp-hint-spinner")).toBeNull(); }); it("puts what the hint answers in its data attributes", () => { diff --git a/src/editor/lsp/hint.ts b/src/editor/lsp/hint.ts index cee3fd6b0..51fe15ed0 100644 --- a/src/editor/lsp/hint.ts +++ b/src/editor/lsp/hint.ts @@ -7,6 +7,7 @@ import { StateEffect, StateField, type Extension } from "@codemirror/state"; import { EditorView, keymap, showTooltip, type Tooltip } from "@codemirror/view"; import { Prec } from "@codemirror/state"; import { txTemplate } from "@/platform/i18n"; +import { spinnerNode } from "@/ui/iconNode"; interface Hint { pos: number; @@ -48,6 +49,7 @@ const hintField = StateField.define({ Object.assign(dom.dataset, h.data); if (typeof h.content === "string") { dom.textContent = txTemplate(h.content); + if (h.pending) dom.prepend(spinnerNode(12, "cm-lsp-hint-spinner")); return { dom }; } const built = h.content(); diff --git a/src/editor/lsp/theme.ts b/src/editor/lsp/theme.ts index 4066b8f68..083650095 100644 --- a/src/editor/lsp/theme.ts +++ b/src/editor/lsp/theme.ts @@ -335,6 +335,7 @@ export const lspTheme = EditorView.theme({ boxShadow: "var(--shadow-popup)", whiteSpace: "pre-wrap", }, + ".cm-lsp-hint-spinner": { display: "inline-flex", verticalAlign: "-2px", marginRight: "var(--space-2)" }, // The hint is the tooltip element itself: beat the editor theme's `.cm-tooltip` width. ".cm-tooltip.cm-lsp-hint": { maxWidth: "min(480px, 100%)" }, ".cm-lsp-hint-error": {