-
Notifications
You must be signed in to change notification settings - Fork 185
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
Add setting to render code lenses as a phantom #1750
Conversation
6f29038
to
b1bbcf8
Compare
I've fixed the review comments.
Ideally, the code lens would be re-calculated when there are modifications. I'd personally use
I think this one's in the same vein as the one above, which is to re-calculate code lenses on modification. I'm not entirely sure if it fixes it but I'm willing to try.
I've seen this one before myself! I don't know what causes it other than maybe the server sending duplicates (unlikely?) or some state not being cleared properly. I think I need LSP server logs to figure it out but I'd love to get it fixed as well. |
b1bbcf8
to
9960ddd
Compare
I've force pushed the changesets to rebase from the previous refactoring and it's ready for review again. |
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.
There is unused resolved_code_lens
method in CodeLensView
.
And the unresolved_visible_code_lens
should end with *lenses
IMO.
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 major problem I have with this is that phantoms are not attached to their actual region they represent. This causes all kinds of problems when modifying the buffer, for instance:
Schermopname.2021-06-26.om.12.15.03.mov
Use sublime.LAYOUT_BELOW
and attach to the region it's meant to be attached to. We will have to wait for sublimehq/sublime_text#4469, if ever implemented.
This is starting to look really clean. Hopefully we get a |
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.
This also adds a setting to disable the rendering entirely.
In order to satisfy those who like their code lenses as an annotation I kept the setting as-is rather than replacing them. I did change the default setting to use a phantom since that representation is probably more common for those coming from VSCode.
I've tested this code and it works, but I'm unsure if there are any state related bugs. One thing I noticed is that the code lenses only show up when the file is reopened. This felt undesirable to me, however I did not know where exactly to fix it. In a normal plugin lifecycle I would hook into
on_load_async
,on_activated_async
, and (potentially)on_post_save_async
. There was the_register_async
helper function which would have felt like an appropriate place to send the code lenses request, but I was unsure if the state was properly set there or if this was even desirable. Personally, reopening the file to get code lenses is a bad experience.Code lenses with the
phantom
setting are rendered similarly to VSCode, as seen below: