-
Notifications
You must be signed in to change notification settings - Fork 184
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
Feature: Truncate inlay hint label #2514
Conversation
Could you use I wonder whether this really needs a setting, maybe long labels could instead always be truncated if we pick a reasonable cutoff length? And if the label gets truncated, it could be added to the tooltip, so you can easily see the full inlay hint on mouse hover. So in that case the Line 145 in f4223d6
and Line 170 in f4223d6
Could be useful to try whether that works and how it would look like. |
Maybe we should make this configurable from the preferences? Or is this redundant?
I'll try to implement that. I am not sure how we would choose a reasonable length, because it might vary by language and user preference, someone might be fine with big inlay hints, but other people would want to have very short inlay hints. |
We strive to limit the number of exposed options so no. But also |
✅ Deploy Preview for sublime-lsp ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for sublime-lsp ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for sublime-lsp ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
I think a better default length would be something like 30 or 40, and I would probably name the setting "inlay_hints_truncate_length" or "inlay_hints_max_length" (just a suggestion). |
plugin/inlay_hint.py
Outdated
|
||
remaining_truncate_limit = truncate_limit | ||
full_label = "".join(label_part['value'] for label_part in label) | ||
full_label_truncated = len(full_label) >= truncate_limit and truncate_limit > 0 |
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.
Should this also be >
here or not?
I have tested the PR with a server that uses the regular label (no label parts) and I think it works well with the tooltips.
My only suggestion left would be to use a lower default value for the setting. I think 30 would be a sane default. I would say the truncation is actually a good thing to do, and some users might not check settings or read update notes, so it should be applied by default. Opinions?
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.
Should this also be
>
here or not?I have tested the PR with a server that uses the regular label (no label parts) and I think it works well with the tooltips.
My only suggestion left would be to use a lower default value for the setting. I think 30 would be a sane default. I would say the truncation is actually a good thing to do, and some users might not check settings or read update notes, so it should be applied by default. Opinions?
I'll check it out. Thanks for pointing that out.
I think inlay hint is not enabled by default, so most users will not be affected. So I agree that this feature should be enabled by default. I'll wait for more opinions.
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.
LSP.sublime-settings
Outdated
@@ -180,6 +180,9 @@ | |||
// or a custom keybinding. | |||
"show_inlay_hints": false, | |||
|
|||
// Maximum length for inlay hints. Truncates exceeding characters and adds an ellipsis. Zero or less means no truncation. |
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.
A linebreak would be nice here. Less than zero would violate the JSON schema btw.
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.
I pushed a small change for the description.
Is there anything more or can we merge the PR? (I have tested only for the regular inlay hints without label parts)
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.
I pushed a small change for the description.
Is there anything more or can we merge the PR? (I have tested only for the regular inlay hints without label parts)
I think it is ready to use. I don't have any more changes.
Thanks to all reviewers for their patience!
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.
A linebreak would be nice here. Less than zero would violate the JSON schema btw.
Linebreak after each sentence, if I understand correctly
Description
This pull request allows inlay hints to be truncated, which could be useful if inlay hints are too large. For example: TypeScript has absurdly long inlay hints (see screenshot 1).
The default truncate limit is 1000.
Truncated content reveal is not implemented, which means you cannot see the full content of the inlay hint if it is truncated.Tested with:
LSP-typescript
LSP-gopls
LSP-rust-analyzer
1. Long inlay hint
2. `LSP-typescript` (limit 30)
3. `LSP-gopls` (limit 30)
4. `LSP-rust-analyzer` (limit 30)