-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
See #6417 instead [Feat: CodeLens-style diagnostics] #6059
See #6417 instead [Feat: CodeLens-style diagnostics] #6059
Conversation
This branch should work correctly but I want to refacto and split it into proper commits, I'm just pushing so that other people can try it out |
Thanks for working on this, I am really lookimg forward to.this! Already looks great! I haben't done a full review yet since you aren't done but I have some foundational comments that I think are good to make as early as possible to avoid duplicate work: The way you compute the exact position where to render a message is not quite correct. Fundementally due to softwrap and virtual text the on screen position can not ne computed from the text and can change at any time fully async. Instead the idea is that these decorations are anchored to a char position. When we render we already know the exact onscreen position of each char anyway. The idea is basically that multiline virtual text should only be computed lazily (when visible) in the rendering code. In general the entire idea is that on screen positions are only temporary. Everything that is stored for longer periods is stored as char offsets that get translated to screen coordinates then back. I should write more documentation for that (and maybe even a design doc) but I am sadly busy at the moment. I actually hadn't thought how to do to handle this specific usecase 100% yet. There is a second API to hook into the rendering: TranslatePosition.These are called when a specific char index is reached with the screen position of that char index. This is a lot closer to what you need. It doesn't quite fit your usecase because you still need to accumelate all positions of the current line and then finally render then (because diagnostics rendering stack right to left not left to right). The right way to do this is probably to unify these two APIs so you can have a single struct which accumulates positions and then renders them. For now I think you could just start by using BTW. a small code clarity thing: I would prefer if we didn't keep adding too much code to ui/editor.rs. I purposfukly modularized the text rendering to avoid that. Since |
d546761
to
fc06318
Compare
@pascalkuthe thanks for the tip, I tested with the inlay-hint branch to fix and now it works much better ^^(sill not ready for review, the code is a mess right now, documentation is wrong everywhere too after that fix) |
fc06318
to
57dced0
Compare
This is ready for review but there are still several problems I know of: The cursor will go out of view when diagnostics are displayed. I think the In the same vein, I was forced to make commit 4d3ef39 because when the top of the file is modified (for example by rust-analyzer inserting a missing import) while out of the view, it would panic. I think I did something wrong but it's late and that fix make it "work" (i.e. not crash) so that's good enough to ask for help and review. Finally, when updating text out of view, because of the previous fix I think diagnostics are not moved correctly so we end up with things like the screenshot below (appears after asking rust-analyzer to insert the missing import for Again, not a crash so I'll take it for now. I would like to see it fixed though |
After a quick scan I already have some comments but I am actually working on the improve rendering API I mentioned earlier and those comments are related to do that so I will holdoff a review until I am finished. Hopefully tomorrow if nothing comes up. I think 4d3ef39 might be a legitimate bug although the cursor going out of view should also not happen. That should ne properly accounted for but I might habe missed something. Howber the diagnostic mapping should not be affected by any of this so that sounds like a separate bug. |
The cursor offset has error at view bottom. When the file content has multiple pages ,cursor will be keep at view bottom when have multiline diagnostics message and use k moving. Whether to update |
57dced0
to
9f4cfad
Compare
Yes it's a known problem, see my previous message, I don't know where it comes from though |
@CptPotato did you test on the latest version ? I fixed a bug that highlighted the lines wrong (it used the diagnostic on the same line instead of the target diagnostic), now it works like this:
Yes, that's a good idea, will do |
Thanks for the hint. This way it gets rid of the visual artifact, too 👍
If you do, I think a theme key like |
9f4cfad
to
a8b5d86
Compare
@CptPotato Added a default style under @pascalkuthe I discovered a bug where I trigger the assertion in |
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.
Awesome job! i really like the style of the diagnostics!
a8b5d86
to
883a6db
Compare
@SoraTenshi thanks for the find, I had planned to search for it but you made it a 100 times easier 😄 it should be fixed now There is still the bug with the cursor going out of view and the |
Have you figured out how to reproduce it? |
Yeah it needs to be softwrapped but variable height virtual text isn't currently supported by the virtual text API. I don't have much time at the moment but next week I will post a PR to expand the virtual text API to cover this usecase. I actually have a similar need for side by side diffing so it's needed anyway. This PR also has a bunch of bugs that are partly caused by the virtual text API being limited (and partly by it not being used correctly). Once I have update the virtual text API I will do an indepth review. |
883a6db
to
9ff3bdd
Compare
…s from the LSP server
… for pretty much no gain
653eff1
to
2c5dcfa
Compare
how soon can we expect to see this? looks awesome |
Since some stuff weren't mentioned here I think it would be nice to have them mentioned somewhere. Therefore, I'll leave it here just as a note. And thanks for this awesome PR beforehand.
[editor.lsp]
code-lens.enabled = true # or false
[editor.lsp]
code-lens.style = "default" # or "toggleable" ?? Thanks again for this awesome feature! |
I see a few mentions of verbosity, toggling with a keybinding, etc, so I'll throw another idea in the hat: would it be useful to treat diagnostic severity levels similar to application log levels? For example [editor.lsp]
code-lens.level = "warn" Would show warnings and errors inline with the source code as implemented by this PR, but info and hint diagnostics would require triggering a pop-up of some kind. Thanks for the PR either way! I have been using and enjoying this for a few weeks now. |
Superseded by #6417 That PR contains a bunch of bug fixes and architectural improvements to the virtual text API and a complete reimplementation of this PR on top of the improved API (and to enable soft wrapping). This should fix the artifacts and crashes reported here. That branch also contains a bunch of additional improvements:
It would be great if that PR was tested more to shake out any remaining bugs in the virtual text rendering (although I hopefully got most of them). It's still missing some docs but apart from that it should work well. |
I filed #7015 due to a UX problem with 0.6.0 in which brainstormed a different UI. Then I discovered this, which is better than what I imagined while addressing my problem well. Closed my ticket. 👍 and Kudos! |
Replaced by #6417
Closes #3272