diff --git a/src/features/code-insight/UsagesPopup.tsx b/src/features/code-insight/UsagesPopup.tsx index 931a76d4af..2e323fd430 100644 --- a/src/features/code-insight/UsagesPopup.tsx +++ b/src/features/code-insight/UsagesPopup.tsx @@ -228,9 +228,11 @@ function UsagesPopupInner() {
{symbol ? tx`Usages of ${symbol}` : tx("Usages")}{" "} - - {filter || items.length !== total ? tx`${items.length} of ${total} found` : tx`${total} found`} - + {(total > 0 || !loading) && ( + + {filter || items.length !== total ? tx`${items.length} of ${total} found` : tx`${total} found`} + + )}
diff --git a/src/features/code-insight/usagesPopup.test.tsx b/src/features/code-insight/usagesPopup.test.tsx index 5b528ab1bd..e2a5d16e6f 100644 --- a/src/features/code-insight/usagesPopup.test.tsx +++ b/src/features/code-insight/usagesPopup.test.tsx @@ -362,6 +362,7 @@ it("opens while a slow search has found nothing yet, and closes when it ends wit await act(() => new Promise((r) => setTimeout(r, 350))); expect(useUsagesPopup.getState()).toMatchObject({ open: true, loading: true, groups: [] }); expect(screen.getByText("Searching for usages…")).toBeInTheDocument(); + expect(screen.queryByText("0 found")).not.toBeInTheDocument(); await act(async () => { resolve({ locations, incomplete: null }); await pending; @@ -385,6 +386,23 @@ it("opens while a slow search has found nothing yet, and closes when it ends wit expect(calls.slice(before)).toEqual(["hint No usages of 'used' found"]); }); +it("shows the count once a search in the open popup ends with none", async () => { + render(); + const at = (line: number) => ({ ...loc, range: { start: { line, col: 4 }, end: { line, col: 8 } } }); + referenceResponse.mockResolvedValueOnce({ locations: [], incomplete: null, librariesSkipped: true }); + await showUsagesPopup(); + referenceResponse.mockResolvedValueOnce({ locations: [at(1), at(2)], incomplete: null }); + await act(() => showUsagesPopup()); + expect(useUsagesPopup.getState()).toMatchObject({ open: true, scope: "libraries" }); + expect(screen.getByText("2 found")).toBeInTheDocument(); + referenceResponse.mockResolvedValueOnce({ locations: [], incomplete: null, librariesSkipped: true }); + await act(async () => setUsagesPopupScope("project")); + await vi.waitFor(() => expect(useUsagesPopup.getState()).toMatchObject({ loading: false, scope: "project" })); + expect(useUsagesPopup.getState().open).toBe(true); + expect(screen.getByText("0 found")).toBeInTheDocument(); + act(() => dismissUsagesPopup()); +}); + it("searches Project Files, and Project and Libraries when invoked again", async () => { render(); const at = (line: number) => ({ ...loc, range: { start: { line, col: 4 }, end: { line, col: 8 } } });