-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Fix tree sitter to output 1-based line numbers #2236
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
|
@KJ7LNW how does this look? Thanks! |
|
lgtm. can you also clamp startLine to go no lower than zero (at this point in the code it is always zero indexed): src/integrations/misc/read-lines.ts-25-export function readLines(filepath: string, endLine?: number, startLine?: number): Promise<string> {
<<clamp startLine force >= 0 -- at this point in the code it is always zero indexed>>
src/integrations/misc/read-lines.ts-26- return new Promise((resolve, reject) => {
src/integrations/misc/read-lines.ts-27- // Validate input parameters
src/integrations/misc/read-lines.ts-28- // Check startLine validity if provided
src/integrations/misc/read-lines.ts-29- if (startLine !== undefined && (startLine < 0 || startLine % 1 !== 0)) {
src/integrations/misc/read-lines.ts-30- return reject(
src/integrations/misc/read-lines.ts:31: new RangeError(`Invalid startLine: ${startLine}. Line numbers must be non-negative integers.`),
src/integrations/misc/read-lines.ts-32- )
src/integrations/misc/read-lines.ts-33- }
src/integrations/misc/read-lines.ts-34-it will prevent this error if the model provides 0 as a number: <read_file>
<path>.build/linux/rpm/x86_64/rpmbuild/SPECS/code-oss.spec</path>
<start_line>0</start_line>
<end_line>50</end_line>
</read_file>
<error>
Error reading file: {"name":"RangeError","message":"Invalid startLine: -1. Line numbers must be non-negative integers.","stack":"RangeError: Invalid startLine: -1. Line numbers must be non-negative integers.\n at /home/ewheeler/.vscode-insiders/extensions/rooveterinaryinc.roo-cline-3.11.3/dist/extension.js:1532:2592\n at new Promise (<anonymous>)\n at Pwe (/home/ewheeler/.vscode-insiders/extensions/rooveterinaryinc.roo-cline-3.11.3/dist/extension.js:1532:2533)\n at MVr (/home/ewheeler/.vscode-insiders/extensions/rooveterinaryinc.roo-cline-3.11.3/dist/extension.js:2016:1666)\n at t.presentAssistantMessage (/home/ewheeler/.vscode-insiders/extensions/rooveterinaryinc.roo-cline-3.11.3/dist/extension.js:3241:793)"} |
Yeah let me do that in another PR |
#2227
Important
Change line number output to 1-based in
processCaptures()and update tests accordingly.processCaptures()inindex.ts.index.test.tsandmarkdownIntegration.test.tsto expect 1-based line numbers.index.test.tsandmarkdownIntegration.test.tsto reflect 1-based indexing.This description was created by
for eb4e2b6. It will automatically update as commits are pushed.