diff --git a/src/App.svelte b/src/App.svelte index 4ba1889..f086c45 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -377,14 +377,14 @@ $: localBranchNames = localBranches.map((b) => b.name); $: remoteBranches = branches.filter((b) => b.remote); $: repoSearchTerm = repoSearch.trim().toLowerCase(); - $: openRepoRows = repoTabs.filter(repoMatchesSearch); + $: openRepoRows = repoTabs.filter((repo) => repoMatchesSearch(repo, repoSearchTerm)); $: recentRepoRows = recentRepoPaths .filter((path) => !repoTabs.some((tab) => sameRepoPath(tab.path, path))) - .map(repoRowFromPath) - .filter(repoMatchesSearch); + .map((path) => repoRowFromPath(path, repoTabs, repoStatusCache)) + .filter((repo) => repoMatchesSearch(repo, repoSearchTerm)); $: favoriteRepoRows = favoriteRepoPaths - .map(repoRowFromPath) - .filter(repoMatchesSearch); + .map((path) => repoRowFromPath(path, repoTabs, repoStatusCache)) + .filter((repo) => repoMatchesSearch(repo, repoSearchTerm)); $: leftSidebarRows = buildLeftSidebarRows(branchPanelCollapsed, stashPanelCollapsed, explorerPanelCollapsed); $: allLeftPanelsCollapsed = branchPanelCollapsed && stashPanelCollapsed && explorerPanelCollapsed; @@ -949,11 +949,11 @@ return result; } - function repoRowFromPath(path: string): RepoTab { - const openTab = repoTabs.find((tab) => sameRepoPath(tab.path, path)); + function repoRowFromPath(path: string, tabs = repoTabs, statusCache = repoStatusCache): RepoTab { + const openTab = tabs.find((tab) => sameRepoPath(tab.path, path)); if (openTab) return openTab; - const cached = repoStatusCache[repoKey(path)]; + const cached = statusCache[repoKey(path)]; if (cached) return { ...cached, path, name: repoNameFromPath(path) }; return { @@ -967,11 +967,11 @@ }; } - function repoMatchesSearch(repo: RepoTab): boolean { - if (!repoSearchTerm) return true; - return repo.name.toLowerCase().includes(repoSearchTerm) - || repo.path.toLowerCase().includes(repoSearchTerm) - || (repo.branch ?? "").toLowerCase().includes(repoSearchTerm); + function repoMatchesSearch(repo: RepoTab, searchTerm = repoSearchTerm): boolean { + if (!searchTerm) return true; + return repo.name.toLowerCase().includes(searchTerm) + || repo.path.toLowerCase().includes(searchTerm) + || (repo.branch ?? "").toLowerCase().includes(searchTerm); } function loadRepoLists() {