дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-05 09:41:34 +02:00
fix(code-insight): hide the usage count while Show Usages is still searching with nothing found (#8041)
Show Usages opens 300 ms into a slow search, before anything is found, and its header then read "0 found" as if the search had finished empty. The count is hidden while the search runs with no results; the header spinner and "Searching for usages…" show progress, and the count appears once usages arrive or the search ends. Refs #6823 Co-authored-by: audichuang <[email protected]>
Цей коміт міститься в:
1 джерело
40fb4923e6
коміт
49e26d1de1
2 files changed
+23
-3
No files matched your search
@@ -228,9 +228,11 @@ function UsagesPopupInner() {
|
||||
<div className={styles.header} data-popup-drag>
|
||||
<span className={styles.title}>
|
||||
<span className={styles.titleLabel}>{symbol ? tx`Usages of ${symbol}` : tx("Usages")}</span>{" "}
|
||||
<span className={styles.count}>
|
||||
{filter || items.length !== total ? tx`${items.length} of ${total} found` : tx`${total} found`}
|
||||
</span>
|
||||
{(total > 0 || !loading) && (
|
||||
<span className={styles.count}>
|
||||
{filter || items.length !== total ? tx`${items.length} of ${total} found` : tx`${total} found`}
|
||||
</span>
|
||||
)}
|
||||
</span>
|
||||
<div className={styles.actions}>
|
||||
<UsageAccessFilter items={all} />
|
||||
|
||||
@@ -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(<UsagesPopup />);
|
||||
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(<UsagesPopup />);
|
||||
const at = (line: number) => ({ ...loc, range: { start: { line, col: 4 }, end: { line, col: 8 } } });
|
||||
|
||||
Reference in new issue
Заблокувати користувача