From 157fa2b77ff1f70d05913ca258eda11182ff87d9 Mon Sep 17 00:00:00 2001 From: xintaofei Date: Sun, 15 Mar 2026 18:33:50 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D.gitignore=E4=B8=80=E5=A4=84?= =?UTF-8?q?=E5=AD=90=E7=9B=AE=E5=BD=95/=E5=AD=90=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E7=9D=80=E8=89=B2=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../layout/aux-panel-file-tree-tab.tsx | 29 +++++++++++++++---- 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/src/components/layout/aux-panel-file-tree-tab.tsx b/src/components/layout/aux-panel-file-tree-tab.tsx index 5afbce4..23ddab2 100644 --- a/src/components/layout/aux-panel-file-tree-tab.tsx +++ b/src/components/layout/aux-panel-file-tree-tab.tsx @@ -1102,14 +1102,31 @@ export function FileTreeTab() { const result = await readFilePreview(folder.path, gitignoreNode.path) const matcher = ignore().add(result.content) - for (const child of children) { + // Collect all descendant nodes so multi-level patterns like + // "public/vs" can be matched using relative paths. + const descendants: FileTreeNode[] = [] + const collectDescendants = (parent: string) => { + const items = dirChildrenByPath.get(parent) + if (!items) return + for (const item of items) { + descendants.push(item) + if (item.kind === "dir") collectDescendants(item.path) + } + } + collectDescendants(dirPath) + + for (const desc of descendants) { + if (hasIgnoredAncestor(desc.path, nextIgnoredPaths)) continue + const relativePath = + dirPath === "" ? desc.path : desc.path.slice(dirPath.length + 1) + if (!relativePath) continue const ignored = - child.kind === "dir" - ? matcher.ignores(`${child.name}/`) || - matcher.ignores(`${child.name}/.codeg-ignore-probe`) - : matcher.ignores(child.name) + desc.kind === "dir" + ? matcher.ignores(`${relativePath}/`) || + matcher.ignores(`${relativePath}/.codeg-ignore-probe`) + : matcher.ignores(relativePath) if (ignored) { - nextIgnoredPaths.add(child.path) + nextIgnoredPaths.add(desc.path) } } } catch {