-
-
Notifications
You must be signed in to change notification settings - Fork 390
feat: Omit parameter hints when the argument name matches #3313
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
base: master
Are you sure you want to change the base?
Conversation
Summary of ChangesHello @roife, 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 enhances the user experience of inlay hints by intelligently suppressing parameter name hints when they are redundant. By comparing the argument's name with the parameter's name, the system avoids displaying unnecessary labels, leading to a cleaner and more focused code view. This change is accompanied by a new, thorough test file to validate the behavior of various inlay hint types. 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
|
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 new test cases for inlay hints, specifically covering type hints, parameter name hints, and array index hints. A change was made to the paramName function in script/core/hint.lua to prevent parameter name hints from appearing when an argument's name is identical to the parameter's name. The reviewer acknowledges the new tests but suggests adding a further test case for paramName set to 'All' to ensure that hints are correctly displayed when a string literal's value matches a parameter name, as the current implementation might incorrectly omit such hints.
| local first, second | ||
| foo(<!first!>, <!second!>) | ||
| ]], {}) | ||
|
|
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.
It's great that you've added tests for the new functionality! To make the tests more comprehensive, consider adding a test case for when a string literal's value matches a parameter name. The current implementation might incorrectly omit the hint in this scenario, and this test would help verify the correct behavior.
For example, with paramName set to 'All', a call like foo('s') to a function function foo(s) end should still display the s: hint.
config.set(nil, 'Lua.hint.paramName', 'All')
TEST([[
local function foo(s)
end
foo(<!'s'!>)
]], {
{
pos = 1,
text = 's:',
kind = define.InlayHintKind.Parameter,
where = 'left',
},
})
e7727d9 to
ca31f4f
Compare
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.
Pull request overview
This PR enhances the inlay hint feature by omitting parameter name hints when the argument name matches the parameter name, reducing visual clutter in the code editor. The change applies to the Lua Language Server's hint system when using the 'All' parameter hint mode.
Key Changes
- Modified parameter hint logic to skip hints when argument variable names match parameter names
- Added comprehensive test suite for the inlay hint feature
- Integrated the new test file into the test runner
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| script/core/hint.lua | Added condition param[1] ~= arg[1] to skip hints when argument name matches parameter name |
| test/inlay_hint/init.lua | New test file with comprehensive coverage for inlay hints including type hints, parameter hints, and array index hints |
| test.lua | Added 'inlay_hint' to the test suite execution list |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Skip parameter name inlay hints when the argument name matches the parameter to avoid redundant labels.
DEMO
Before omitting:
After omitting: