-
Notifications
You must be signed in to change notification settings - Fork 89
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
fix: handle empty lines for languages with semantic whitespace #99
Conversation
WalkthroughThe recent update introduces a modular approach to adjusting ranges within the codebase by extracting the Changes
Assessment against linked issues
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
I'm not sure we actually want to do this. The root cause of that issue looked like a problem in Monaco, not anything in GritQL. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files selected for processing (2)
- crates/core/src/binding.rs (2 hunks)
- crates/core/src/test.rs (1 hunks)
Additional comments: 3
crates/core/src/binding.rs (2)
- 106-115: The
adjust_ranges
function correctly iterates over substitutions and adjusts the ranges based on the provided index and delta. However, there's a potential risk of integer overflow when casting fromisize
tousize
. Consider adding a safety check to ensure that the resulting value is not negative before casting.- 150-152: The handling of empty lines by adjusting ranges with a negative delta is a crucial part of the fix for handling trailing whitespace in languages with semantic whitespace. Consider adding a comment here to explain the rationale behind this approach for future maintainability.
crates/core/src/test.rs (1)
- 12889-12918: The test function
python_support_empty_line
is well-structured and appears to correctly simulate the scenario of handling empty lines in Python code snippets. However, for future maintainability, consider adding a comment explaining the purpose of the test and the specific issue it addresses.
the code is valid regardless of the whitespace on the empty line, I ran the python. I'm sure people have empty lines in their codebases in the middle of a code block I don't see why we shouldn't support that. |
fixes: #84
lines containing only whitespace will be rewritten as empty lines
Summary by CodeRabbit