diff --git a/src/features/settings/__tests__/projectDependencies.test.ts b/src/features/settings/__tests__/projectDependencies.test.ts index 446840e0b..ecc048ced 100644 --- a/src/features/settings/__tests__/projectDependencies.test.ts +++ b/src/features/settings/__tests__/projectDependencies.test.ts @@ -30,18 +30,8 @@ describe("project dependencies", () => { ).toEqual(["/shared", "/deps/lib"]); }); - it("builds the checklist of one root", () => { - const rows = dependencyCandidates("/p/root", ["/deps/lib"], { - recents: [ - { path: "/w/other", name: "Other" }, - { path: "/p/root", name: "Root" }, - { path: "/p/root/sub", name: "Sub" }, - { path: "/deps/lib", name: "lib" }, - ], - }); - expect(rows).toEqual([ - { path: "/deps/lib", name: "lib", checked: true, disabled: false }, - { path: "/w/other", name: "Other", checked: false, disabled: false }, - ]); + it("builds the checklist of one root from its configured projects", () => { + const rows = dependencyCandidates("/p/root", ["/deps/lib", "/deps/lib", "/p/root", "/p/root/sub"]); + expect(rows).toEqual([{ path: "/deps/lib", name: "lib", checked: true, disabled: false }]); }); }); diff --git a/src/features/settings/languages/ProjectStructurePage.tsx b/src/features/settings/languages/ProjectStructurePage.tsx index d92bb91d6..5fae4be99 100644 --- a/src/features/settings/languages/ProjectStructurePage.tsx +++ b/src/features/settings/languages/ProjectStructurePage.tsx @@ -25,7 +25,7 @@ import { import { SettingsFormContext } from "@/workbench/contributions"; import { call, commands, isTauri, nextRequestId, type FileEntry } from "@/platform/ipc"; import { mergeLibraryGroups } from "@/platform/libraries"; -import type { BuildModel, LibraryGroup, RecentProject, WebArtifact } from "@/bindings"; +import type { BuildModel, LibraryGroup, WebArtifact } from "@/bindings"; import { relativePath, useProject } from "@/platform/project"; import { PageContext, useSettingsFormFor } from "../components/context"; import { @@ -606,13 +606,10 @@ export interface DependencyCandidate { /** * Rows of the "project dependencies" checklist of a single root (the project folder, or a - * workspace member): the configured dependencies first, then recent projects as candidates. + * workspace member): the configured dependencies. A workspace additionally lists the other + * roots attached to the window, in MemberDependencies. */ -export function dependencyCandidates( - root: string | null, - dependencies: readonly string[], - options: { recents?: ReadonlyArray<{ path: string; name: string }> } = {}, -): DependencyCandidate[] { +export function dependencyCandidates(root: string | null, dependencies: readonly string[]): DependencyCandidate[] { const out: DependencyCandidate[] = []; const listed = new Set(); const nameOf = (p: string) => p.slice(p.lastIndexOf("/") + 1).replace(/[\\/]+$/, "") || p; @@ -622,11 +619,6 @@ export function dependencyCandidates( listed.add(p); out.push({ path: p, name: nameOf(p), checked: true, disabled: false }); } - for (const r of options.recents ?? []) { - if (listed.has(r.path) || !attachable(r.path)) continue; - listed.add(r.path); - out.push({ path: r.path, name: r.name || nameOf(r.path), checked: false, disabled: false }); - } return out; } @@ -641,21 +633,9 @@ function ModuleDependenciesTab() { function ProjectDependencies() { const root = useProject((s) => s.project?.root ?? null); const [deps, setDeps] = useProjectSetting("projectStructure.dependencies"); - const [recents, setRecents] = useState([]); - - useEffect(() => { - let live = true; - void commands - .recentProjects() - .then((rs) => live && setRecents(rs)) - .catch(() => {}); - return () => { - live = false; - }; - }, []); - const list = deps ?? []; - const candidates = useMemo(() => dependencyCandidates(root, deps ?? [], { recents }), [root, deps, recents]); + // Only the configured projects: candidates come from Add Project…, not every recent project. + const candidates = useMemo(() => dependencyCandidates(root, deps ?? []), [root, deps]); const toggle = (path: string, checked: boolean) => setDeps(checked ? [...list, path] : list.filter((x) => x !== path)); @@ -680,7 +660,7 @@ function ProjectDependencies() {
{candidates.length === 0 && (
- No candidate projects. Recently opened projects appear here. + No candidate projects yet. Use Add Project… to pick one.
)} {candidates.map((c) => ( diff --git a/src/platform/locales/text/en.json b/src/platform/locales/text/en.json index 1ee596913..c4df91fe4 100644 --- a/src/platform/locales/text/en.json +++ b/src/platform/locales/text/en.json @@ -883,7 +883,7 @@ "The project depends on these projects": "The project depends on these projects", "The project depends on {name}": "The project depends on {name}", "Dependency projects are indexed and navigable together with this project: Go to Declaration, Find Usages and the Project view include them.": "Dependency projects are indexed and navigable together with this project: Go to Declaration, Find Usages and the Project view include them.", - "No candidate projects. Recently opened projects appear here.": "No candidate projects. Recently opened projects appear here.", + "No candidate projects yet. Use Add Project… to pick one.": "No candidate projects yet. Use Add Project… to pick one.", "Roots": "Roots", "Dependencies of {name}": "Dependencies of {name}", "The root depends on these projects": "The root depends on these projects", diff --git a/src/platform/locales/text/zh.json b/src/platform/locales/text/zh.json index 2acab9ac7..e7e1bb949 100644 --- a/src/platform/locales/text/zh.json +++ b/src/platform/locales/text/zh.json @@ -7215,7 +7215,7 @@ "The project depends on these projects": "项目取决于这些项目", "The project depends on {name}": "项目取决于 {name}", "Dependency projects are indexed and navigable together with this project: Go to Declaration, Find Usages and the Project view include them.": "依赖项目将与本项目一起建立索引并参与导航:“转到声明”、查找用法和项目视图都会包含它们。", - "No candidate projects. Recently opened projects appear here.": "暂无候选项目。最近打开的项目会显示在这里。", + "No candidate projects yet. Use Add Project… to pick one.": "暂无候选项目。使用「添加项目…」选择。", "Add Project…": "添加项目…", "Roots": "根", "Dependencies of {name}": "{name} 的依赖项",