fix(cmd): handle UTF-8 characters correctly in diagnostic printing#479
fix(cmd): handle UTF-8 characters correctly in diagnostic printing#479fansenze merged 2 commits intoweb-infra-dev:mainfrom
Conversation
Summary of ChangesHello @magic-akari, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request resolves an issue where the Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
The pull request correctly addresses the handling of UTF-8 characters in diagnostic printing. The changes involve importing the unicode/utf8 package, renaming lastNonSpaceIndex to lastNonSpaceByteIndex for clarity, and adjusting the loop logic to explicitly track byte positions using bytePos and utf8.RuneLen. This ensures that line start and end calculations are accurate for multi-byte characters, improving the correctness of diagnostic output.
There was a problem hiding this comment.
Pull request overview
This pull request attempts to fix UTF-8 multi-byte character rendering issues in diagnostic output (issue #478). The changes modify the printDiagnosticDefault function in cmd/rslint/cmd.go to iterate over runes instead of bytes when calculating line start and end positions for code frame display.
Changes:
- Added
unicode/utf8import for UTF-8 rune handling - Modified code frame calculation loop to iterate by runes while tracking byte positions
- Renamed
lastNonSpaceIndextolastNonSpaceByteIndexfor clarity
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Test cases generated by kimi-k2.5 |
|
@magic-akari Thanks for the PR! It looks like the CI is failing due to some style/linting issues. You'll need to run |
Summary
Related Links
Checklist