Skip to content

armgit / dbx

Public Imported from GitHub
0

25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。

fix(sidebar): match table comments in search

t8y2973e9f487aec
diff --git a/apps/desktop/src/lib/sidebarSearchTree.ts b/apps/desktop/src/lib/sidebarSearchTree.ts
index f5c880de28..564700eaaf 100644
--- a/apps/desktop/src/lib/sidebarSearchTree.ts
+++ b/apps/desktop/src/lib/sidebarSearchTree.ts
@@ -5,6 +5,14 @@ const preserveMatchedSubtreeTypes = new Set(["database", "schema", "table", "vie
const normalizedLabelCache = new WeakMap<TreeNode, { label: string; normalized: string }>();
+function bestMatch(matchLabel: SidebarLabelMatcher, label: string, comment?: string | null) {
+ const lm = matchLabel(label);
+ if (!comment) return lm;
+ const cm = matchLabel(comment.toLowerCase());
+ if (lm && cm) return lm.score >= cm.score ? lm : cm;
+ return lm ?? cm;
+}
+
function normalizedLabel(node: TreeNode): string {
const cached = normalizedLabelCache.get(node);
if (cached?.label === node.label) return cached.normalized;
@@ -30,7 +38,7 @@ function filterSidebarTreeWithMatcher(nodes: TreeNode[], matchLabel: SidebarLabe
const label = normalizedLabel(node);
const canSelfMatch = !searchableNodeTypes || searchableNodeTypes.has(node.type);
- const selfMatch = canSelfMatch ? matchLabel(label) : null;
+ const selfMatch = canSelfMatch ? bestMatch(matchLabel, label, node.comment) : null;
const preservesSubtree = !!selfMatch && preserveMatchedSubtreeTypes.has(node.type);
const filteredChildren = preservesSubtree ? node.children : node.children ? filterSidebarTreeWithMatcher(node.children, matchLabel, collapsedIds, searchableNodeTypes) : undefined;