Skip to content

Comments

Fix off-by-one column offset in ruff parser#25

Merged
ram-nadella merged 3 commits intomainfrom
fix-ruff-column-offset
Jul 19, 2025
Merged

Fix off-by-one column offset in ruff parser#25
ram-nadella merged 3 commits intomainfrom
fix-ruff-column-offset

Conversation

@ram-nadella
Copy link
Owner

Summary

  • Fixed off-by-one error in ruff parser column positions
  • Ruff returns 1-based column indices while the codebase expects 0-based indices
  • Adjusted column calculation to subtract 1 for proper alignment with tree-sitter behavior

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

  • All existing tests pass
  • Code formatted with cargo fmt
  • Code linted with cargo clippy
  • Verified symbol positions now correctly point to the first character of names

🤖 Generated with Claude Code

ram-nadella and others added 2 commits July 19, 2025 16:36
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>
@ram-nadella ram-nadella merged commit 216a926 into main Jul 19, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant