-
Notifications
You must be signed in to change notification settings - Fork 29.4k
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 support for children in Diagnostic object for complex errors #10271
Comments
The |
When @nikomatsakis and I were working on the new errors, one of the ways we envisioned them possibly working may be close to what @dbaeumer (also, hi Dirk! long time no see!) is suggesting. As a first step, I think a diagnostic tree is an okay fix. But I think ideally (and apologies I don't have a mockup so you'll have to visualize), is something like this:
@dbaeumer - does vscode support lightbulbs or additional info notifications? Maybe this is something where the lightbulb could pop up if there are additional notes. |
@jonathandturner (Hi Jonathon, indeed long time no see. See you have fun with rust now) Yes, there is support for a lightbulb in VS Code. Have a look at the code action API. This allows you to provide code actions for every position in the document. We then show the light bulb with the corresponding actions to run. The peak UI for errors is already there. You can pressed F8 in the editor to activate this. |
Long messages are not shown completely in the problems view. A partial message with a I would make this a dup of #1927 if this is only about showing multi line messages in the problems view. |
@sandy081 I don't think this issue is necessarily about multi line messages. Consider the following error:
Presently there doesn't appear (unless I am mistaken) to be a way to add squiggles to lines Allowing for children in the tree (or an alternative means) would allow us to highlight the two borrows which would lead back to the original error. As I understand, the lightbulbs are for code actions and wouldn't really fit the context here as there is no action to be taken. |
@trixnz In the above example, is not it enough to add a single diagnostic entry to line 29 providing a detailed message and mentioning where mutable borrow occurred. I do not think we need to add a squiggle or a child entry for line 27. IMO line 27 is a reference that has to be made in diagnostic entry of line 29. |
+1 - the Flow parser also returns errors in two places - one in the React component which was used, and one in the place where it was used. Right now, the flow plugin shows the error in the first place, but not the second, which is rather pointless. It'd be very helpful if VSCode did have this functionality. |
Fair request and I believe child-diagnostics is powerful to cover various scenarios... Biggest challenge is the slightly bogus design of today-diagnostic, esp. because it doesn't have a location but depends on the DiagnosticsCollection... That needs some careful refactoring. |
@trixnz @jonathandturner Now that we have the API, what UI expectations do you have this?
For the latter in might be cool to actually preview the source code (line) unless the message itself already contains a preview... |
Let me pull in @nrc who is leading the Rust dev tools team and is a good point of contact. They're currently working to push the Rust Language Server work to 1.0, and getting some polish into the VS Code experience for Rust would be an awesome bonus. |
I'll describe what feels like my ideal UI, I have no idea about the implementation difficulty though: In the problem view, only 'primary' diagnostics are displayed, those with related info can be expaned to toggle display of related info:
on-click:
Only 'primary' diagnostics have squiggles, however, if a primary diagnostic is hovered or clicked in the problem view then squiggles are also shown under the related locations. While the user continues to interact with a primary or related diagnostics, all diagnostics related to that primary are squiggled. Likewise, interacting with any primary or related diagnostic in the problems panel causes all primary/related diagnostics in the group (with the same 'parent' diagnostic) to be squiggled. I would not expect to concatenate related info to the hover, but I would expect some indicator that related info exists (some highlighted For Rust, we never include code in the diagnostic messages directly, we keep spans for all relevant locations and then synthesize the code preview into the error message when it is rendered. So you wouldn't ever need to worry about displaying code twice. |
Just to throw another possibility onto the pile that might be worth exploring: For the error messages with multiple locations, like @nrc points out, the primary one is the squiggle. If you click or hover the squiggle, maybe you can get peeks that show off the other locations. I figure a peek (or multiple peeks) might work best since you may not have all the other locations on the same page of code and may require you to jump back and forth. |
Great news! I think it'd also be helpful to take in flow-for-vscode team (@orta ?) to share their requirements, as Flow also has quite a verbose multi-line multi-file diagnostic output. |
Will start exposing this in the Problems Panel tomorrow. |
I've not really used Flow in a year, and since then there's been some amazing improvements on how they report errors - so I'm going to tag in @calebmer who improved them. |
@sandy081 that looks great! It would be really nice if we could squiggle under |
The squiggle on related line might not be visible if the lines are too far apart to be visible in the same viewport, so if only related line is visible then it might look as if |
@agauniyal @sandy081 - can we show the squiggle in the peek window, rather than the (2, 9)? |
Maybe peek window can contain a link to the related line(I've seen this behavior with codelens)? |
Is it possible to see the f8 panel without starting on the main error? If the user has to scroll to only see the related squiggle, then it doesn't seem too bad. Perhaps we could also use different colour squiggles to clarify?
This would be great! |
I'd like encourage to continue the discussion about F8 and related diagnostics in #46562 because this issue has become quite large already. I am also going ahead and I am closing this one so that we can test and ship the first versions of the various pieces involved (API, LSP, problem panel, hover, and F8) |
While working with languages like
Rust
with rich information in its errors, it's become apparent that not all of this information can be conveyed cleanly with the currentProblems
window. Take, for example, this error:The note referencing where the first condition was used would be helpful to the user, but we must omit it because the error list is sorted on the
Range
of the error, resulting in the note being sorted before the actual error:While the above example doesn't look too ambiguous, when there are several errors spread out through the window, it quickly becomes extremely difficult to figure out what relates to each other.
If
Diagnostic
had achildren: Diagnostic[]
field where we could add additional context around the error, we would be able to convey more information to the user about the events that led to the error/warning.The text was updated successfully, but these errors were encountered: