Skip to content

Commit eb4e2b6

Browse files
committed
Fix tree sitter to output 1-based line numbers
1 parent c4af8ca commit eb4e2b6

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

src/services/tree-sitter/__tests__/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ export const CheckboxExample = () => (
309309

310310
// Verify function found and correctly parsed
311311
expect(result).toContain("jsx-arrow.tsx")
312-
expect(result).toContain("4--14 |")
312+
expect(result).toContain("5--15 |")
313313

314314
// Verify line count
315315
const capture = mockQuery.captures.mock.results[0].value[0]

src/services/tree-sitter/__tests__/markdownIntegration.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ describe("Markdown Integration Tests", () => {
3636
// Check the result
3737
expect(result).toBeDefined()
3838
expect(result).toContain("# test.md")
39-
expect(result).toContain("0--4 | # Main Header")
40-
expect(result).toContain("5--9 | ## Section 1")
41-
expect(result).toContain("10--14 | ### Subsection 1.1")
42-
expect(result).toContain("15--19 | ## Section 2")
39+
expect(result).toContain("1--5 | # Main Header")
40+
expect(result).toContain("6--10 | ## Section 1")
41+
expect(result).toContain("11--15 | ### Subsection 1.1")
42+
expect(result).toContain("16--20 | ## Section 2")
4343
})
4444

4545
it("should handle markdown files with no headers", async () => {
@@ -93,7 +93,7 @@ describe("Markdown Integration Tests", () => {
9393
// Check the result
9494
expect(result).toBeDefined()
9595
expect(result).toContain("# mixed-headers.md")
96-
expect(result).toContain("0--3 | # ATX Header")
97-
expect(result).toContain("4--8 | Setext Header")
96+
expect(result).toContain("1--4 | # ATX Header")
97+
expect(result).toContain("5--9 | Setext Header")
9898
})
9999
})

src/services/tree-sitter/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,13 +275,13 @@ function processCaptures(captures: any[], lines: string[], minComponentLines: nu
275275

276276
// Add component name to output regardless of HTML filtering
277277
if (!processedLines.has(lineKey) && componentName) {
278-
formattedOutput += `${startLine}--${endLine} | ${lines[startLine]}\n`
278+
formattedOutput += `${startLine + 1}--${endLine + 1} | ${lines[startLine]}\n`
279279
processedLines.add(lineKey)
280280
}
281281
}
282282
// For other component definitions
283283
else if (isNotHtmlElement(startLineContent)) {
284-
formattedOutput += `${startLine}--${endLine} | ${lines[startLine]}\n`
284+
formattedOutput += `${startLine + 1}--${endLine + 1} | ${lines[startLine]}\n`
285285
processedLines.add(lineKey)
286286

287287
// If this is part of a larger definition, include its non-HTML context
@@ -294,7 +294,7 @@ function processCaptures(captures: any[], lines: string[], minComponentLines: nu
294294
// Add the full range first
295295
const rangeKey = `${node.parent.startPosition.row}-${contextEnd}`
296296
if (!processedLines.has(rangeKey)) {
297-
formattedOutput += `${node.parent.startPosition.row}--${contextEnd} | ${lines[node.parent.startPosition.row]}\n`
297+
formattedOutput += `${node.parent.startPosition.row + 1}--${contextEnd + 1} | ${lines[node.parent.startPosition.row]}\n`
298298
processedLines.add(rangeKey)
299299
}
300300
}

0 commit comments

Comments
 (0)