mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-24 16:04:21 +00:00
feat(editor): spinner in progress hints (#4854)
Pending editor hints (Finding navigation target and other progress hints) start with the ring spinner used elsewhere in the UI; final hints are unchanged.
This commit is contained in:
@@ -30,6 +30,7 @@ describe("pending hints", () => {
|
||||
vi.advanceTimersByTime(PENDING_HINT_DELAY_MS);
|
||||
expect(hint()).toBe("Waiting…");
|
||||
expect(document.querySelector<HTMLElement>(".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<HTMLElement>(".cm-lsp-hint")?.dataset.pending).toBeUndefined();
|
||||
expect(document.querySelector(".cm-lsp-hint-spinner")).toBeNull();
|
||||
});
|
||||
|
||||
it("puts what the hint answers in its data attributes", () => {
|
||||
|
||||
@@ -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<Hint | null>({
|
||||
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();
|
||||
|
||||
@@ -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": {
|
||||
|
||||
Reference in New Issue
Block a user