-
Notifications
You must be signed in to change notification settings - Fork 10.8k
chore: fix lint warnings in DiffRenderer #17265
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
Summary of ChangesHello @jacob314, 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 significantly enhances the Highlights
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
|
|
Size Change: +4.94 kB (+0.02%) Total Size: 23.2 MB
ℹ️ View Unchanged
|
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.
Code Review
This pull request introduces a significant enhancement to the diff renderer by adding word-level highlighting for changed lines, which greatly improves readability. The implementation involves grouping added/deleted lines and using the diff library to compare them. The changes also include extending the theme system to support highlight colors.
My review focuses on the new logic. I've found one issue in the theme creation logic that could lead to incorrect fallback behavior for highlight colors, which has been addressed with a more robust solution.
| diff: { | ||
| added: customTheme.background?.diff?.added ?? colors.DiffAdded, | ||
| addedHighlight: | ||
| customTheme.background?.diff?.addedHighlight ?? | ||
| colors.DiffAddedHighlight ?? | ||
| colors.DiffAdded, | ||
| removed: customTheme.background?.diff?.removed ?? colors.DiffRemoved, | ||
| removedHighlight: | ||
| customTheme.background?.diff?.removedHighlight ?? | ||
| colors.DiffRemovedHighlight ?? | ||
| colors.DiffRemoved, | ||
| }, |
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.
The logic for constructing the diff object within semanticColors is overly complex and contains redundant fallbacks. The colors object, constructed just above, already contains the fully resolved color values from the customTheme.
Additionally, there's a subtle bug: using ?? for fallbacks doesn't handle cases where a highlight color is explicitly set to an empty string (''). In such cases, the fallback to the base added/removed color doesn't occur. Using || ensures that if a highlight color is falsy (like an empty string), it correctly falls back to the base line color. Furthermore, to prevent uninformative messages from whitespace-only strings, it's best practice to trim() the optional string before applying the fallback, ensuring that only truly meaningful values are used.
Simplifying this block to directly use the colors object and the correct fallback operator, along with trimming, will make the code more readable, maintainable, and correct.
diff: {
added: colors.DiffAdded,
addedHighlight:
(colors.DiffAddedHighlight || '').trim() || colors.DiffAdded,
removed: colors.DiffRemoved,
removedHighlight:
(colors.DiffRemovedHighlight || '').trim() || colors.DiffRemoved,
},References
- When using an optional string with a fallback value, trim the optional string and use the fallback if the result is empty to avoid uninformative messages from whitespace-only strings.
|
Hi there! Thank you for your contribution to Gemini CLI. We really appreciate the time and effort you've put into this pull request. To keep our backlog manageable and ensure we're focusing on current priorities, we are closing pull requests that haven't seen maintainer activity for 30 days. Currently, the team is prioritizing work associated with 🔒 maintainer only or help wanted issues. If you believe this change is still critical, please feel free to comment with updated details. Otherwise, we encourage contributors to focus on open issues labeled as help wanted. Thank you for your understanding! |
Summary
Details
Related Issues
How to Validate
Pre-Merge Checklist