You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add support for children in Diagnostic object for complex errors #10271
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 current Problems window. Take, for example, this error:
warning: this `if` has the same condition asa previous if,#[warn(ifs_same_cond)] on by default
--> src\main.rs:6:15
|
6 | }elseif a == b {
| ^^^^^^
|
note: same asthis
--> src\main.rs:4:8
|
4 | if a == b {
| ^^^^^^
= help:for further information visit https://github.com/Manishearth/rust-clippy/wiki#ifs_same_cond
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 a children: 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.
Reacted by Bazyli Brzóska (Zendesk), Josh Wood and Colby Pike
The same as this is IMO not a separate error / problem. The solution to this should be a more complex message instead of a diagnostic tree. Sandeep Somavarapu (@sandy081) what happens with multi line messages today in the problems view.
When Niko Matsakis (@nikomatsakis) and I were working on the new errors, one of the ways we envisioned them possibly working may be close to what Dirk Bäumer (@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:
Errors/Warnings are squiggled, but notes aren't shown
When you click on an Error/Warn squiggle, you get a popup that is like peek. It shows you the rest of the notes that are important, but otherwise these are hidden
Dirk Bäumer (@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 ... is shown at the end. Complete message is shown as title (on hover). For more information refer to this feature request - #1927
I would make this a dup of #1927 if this is only about showing multi line messages in the problems view.
Sandeep Somavarapu (@sandy081) I don't think this issue is necessarily about multi line messages. Consider the following error:
error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable
--> src\main.rs:29:20
|
27 | let y = &mut x;
| - mutable borrow occurs here
28 | *y += 1;
29 | println!("{}", x);
| ^ immutable borrow occurs here
30 | }
| - mutable borrow ends here
Presently there doesn't appear (unless I am mistaken) to be a way to add squiggles to lines 27 and 29 without adding a new diagnostic entry for each, which would be ambiguous when there are other errors to look through. As a result, we can only add the cannot borrowxas immutable because it is also borrowed as mutable line to the diagnostic list.
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.
Cam (@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.
Sandeep Somavarapu (@sandy081) that looks great! It would be really nice if we could squiggle under let x = 5 while this message was shown and/or display a snippet of line 2 in the panel (this might be useful if the message refers to code that is not currently visible, which does often happen).
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 let x = 5 has the error instead.
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 let x = 5 has the error instead.
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?
Maybe peek window can contain a link to the related line(I've seen this behavior with codelens)?
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)
Activity
dbaeumer commentedon Aug 8, 2016
The
same as thisis IMO not a separate error / problem. The solution to this should be a more complex message instead of a diagnostic tree. Sandeep Somavarapu (@sandy081) what happens with multi line messages today in the problems view.sophiajt commentedon Aug 8, 2016
When Niko Matsakis (@nikomatsakis) and I were working on the new errors, one of the ways we envisioned them possibly working may be close to what Dirk Bäumer (@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:
Dirk Bäumer (@dbaeumer) - does vscode support lightbulbs or additional info notifications? Maybe this is something where the lightbulb could pop up if there are additional notes.
dbaeumer commentedon Aug 9, 2016
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.
sandy081 commentedon Aug 15, 2016
Long messages are not shown completely in the problems view. A partial message with a
...is shown at the end. Complete message is shown as title (on hover). For more information refer to this feature request - #1927I would make this a dup of #1927 if this is only about showing multi line messages in the problems view.
trixnz commentedon Aug 15, 2016
Sandeep Somavarapu (@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
27and29without adding a new diagnostic entry for each, which would be ambiguous when there are other errors to look through. As a result, we can only add thecannot borrowxas immutable because it is also borrowed as mutableline to the diagnostic list.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.
sandy081 commentedon Aug 16, 2016
Cam (@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.
kumarharsh commentedon Oct 6, 2017
+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.
22 remaining items
use colon as separator, not – #10271
sandy081 commentedon Mar 20, 2018
Another version closer to what Johannes Rieken (@jrieken) has for F8
Johannes Rieken (@jrieken) Opinions?
#10271 Sync with F8 representation
sandy081 commentedon Mar 21, 2018
Johannes Rieken (@jrieken) Kai Maetzel (@kieferrm)
I set up a
rustexampleProblems generated by the
Rust (rls)extensionProblems with related information generated by my test extension
nrc commentedon Mar 22, 2018
Sandeep Somavarapu (@sandy081) that looks great! It would be really nice if we could squiggle under
let x = 5while this message was shown and/or display a snippet of line 2 in the panel (this might be useful if the message refers to code that is not currently visible, which does often happen).add related diagnostics to hover, #10271
agauniyal commentedon Mar 23, 2018
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
let x = 5has the error instead.sophiajt commentedon Mar 23, 2018
Abhinav Gauniyal (@agauniyal) Sandeep Somavarapu (@sandy081) - can we show the squiggle in the peek window, rather than the (2, 9)?
agauniyal commentedon Mar 23, 2018
Maybe peek window can contain a link to the related line(I've seen this behavior with codelens)?
nrc commentedon Mar 26, 2018
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!
always hide F8 when going to a related marker, #10271
jrieken commentedon Mar 26, 2018
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)