Fix off-by-one column offset in ruff parser#25
Merged
ram-nadella merged 3 commits intomainfrom Jul 19, 2025
Merged
Conversation
The ruff parser returns 1-based column positions while the codebase expects 0-based positions (matching tree-sitter's behavior). This fix subtracts 1 from the column position to convert from 1-based to 0-based indexing. This ensures symbol positions correctly point to the first character of function/class names rather than one character into the name. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Added comprehensive test to verify that both tree-sitter and ruff parsers report consistent column positions for function and class names. This test ensures the fix for the ruff parser's off-by-one column issue is working correctly. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Problem
When using the ruff parser, symbol positions were showing up one character into the definition. For example, with
def my_func():, the position was pointing to the 'y' instead of the 'm'.Solution
The ruff parser returns 1-based column positions (where column 1 is the first character) while the rest of the codebase expects 0-based positions (where column 0 is the first character). This fix converts from 1-based to 0-based by subtracting 1 from the column value.
Test plan
cargo fmtcargo clippy🤖 Generated with Claude Code