mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-11 02:31:38 -10:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
46c89db926 |
No files matched your search
@@ -17,6 +17,7 @@ import {
|
||||
} from "@/ui";
|
||||
import { openLocation } from "./ipc";
|
||||
import {
|
||||
closeHierarchy,
|
||||
ROOT_ID,
|
||||
directionLabel,
|
||||
hierarchyTitle,
|
||||
@@ -64,9 +65,10 @@ export function HierarchyTabs() {
|
||||
variant="compact"
|
||||
className={styles.tabs}
|
||||
aria-label="Hierarchies"
|
||||
items={[{ id: "current", label }]}
|
||||
items={[{ id: "current", label, closable: true }]}
|
||||
activeId="current"
|
||||
onSelect={() => undefined}
|
||||
onClose={closeHierarchy}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2,9 +2,10 @@ import { describe, expect, it, vi } from "vitest";
|
||||
import type { HierarchyItem, OutlineItem, ReferencesIncomplete, SymbolKind } from "@/bindings";
|
||||
|
||||
const hint = vi.fn();
|
||||
const hide = vi.hoisted(() => vi.fn());
|
||||
vi.mock("@/workbench/contributions", async (orig) => ({
|
||||
...(await orig<typeof import("@/workbench/contributions")>()),
|
||||
toolWindowService: () => ({ show: () => undefined }),
|
||||
toolWindowService: () => ({ show: () => undefined, hide }),
|
||||
}));
|
||||
|
||||
const range = (l1: number, c1: number, l2: number, c2: number) => ({
|
||||
@@ -167,3 +168,13 @@ describe("hierarchy", () => {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe("closing the hierarchy tab", () => {
|
||||
it("clears the tree and hides the tool window", async () => {
|
||||
const { closeHierarchy, useHierarchy } = await import("./hierarchy");
|
||||
useHierarchy.setState({ root: { name: "Number", path: "/p/Number.java", line: 0, col: 0 } as never });
|
||||
closeHierarchy();
|
||||
expect(useHierarchy.getState().root).toBeNull();
|
||||
expect(hide).toHaveBeenCalledWith("hierarchy");
|
||||
});
|
||||
});
|
||||
@@ -73,6 +73,12 @@ export function resetHierarchy() {
|
||||
}));
|
||||
}
|
||||
|
||||
/** Closes the hierarchy's content tab; with no content left the tool window hides. */
|
||||
export function closeHierarchy() {
|
||||
resetHierarchy();
|
||||
toolWindowService().hide("hierarchy");
|
||||
}
|
||||
|
||||
/** The empty-result line of the hierarchy tree. */
|
||||
export function noneFoundLabel(mode: HierarchyMode, direction: HierarchyDirection): string {
|
||||
if (mode === "call") return direction === "incoming" ? tx`— no callers found` : tx`— no callees found`;
|
||||
|
||||
Reference in new issue
Block a user