fix(retrieval): end brace-language symbols at top-level braces

Code after a top-level closing brace belonged to the preceding function, for
example shell loops labeled as quote_toml. Attribute it to the module.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Julian lechnerandClaude Opus 5.5 committed 2026-10-01 13:13:05 +02:00
1 parent e138c0277e
commit d60dd10c45
2 files changed
+4

No files matched your search

+3
View File
@@ -119,6 +119,9 @@ def sections(text: str, path: str):
if heading:
boundaries[number] = heading[1]
elif suffix in {".js", ".jsx", ".mjs", ".cjs", ".ts", ".tsx", ".cs", ".java", ".kt", ".kts", ".go", ".rs", ".c", ".cpp", ".ps1", ".psm1", ".sh"}:
# A closing brace in column 0 ends a top-level declaration; code after it belongs to the module again.
if line.startswith("}"):
boundaries.setdefault(number + 1, "<module>")
symbol = re.match(
r"^\s*(?:(?:export|default|public|private|protected|internal|static|abstract|async|sealed|partial|pub)\s+)*"
r"(?:(?:class|interface|struct|enum|record|function|fun|fn|def)\s+([\w$-]+)"