Skip to content
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 the ability to make multiline suggestions/notes #293

Open
RDambrosio016 opened this issue Sep 26, 2020 · 4 comments
Open

Add the ability to make multiline suggestions/notes #293

RDambrosio016 opened this issue Sep 26, 2020 · 4 comments

Comments

@RDambrosio016
Copy link
Contributor

Hello!

I have been working on a large project and a lot of the errors have suggestions attached to them, however, i would greatly appreciate being able to make suggestions like rustc_errors can do. Example:

error: unknown start of token: \u{37e}
 --> main.rs:2:30
  |
2 |    println!("Hello, world!");
  |                             ^
help: Unicode character ';' (Greek Question Mark) looks like ';' (Semicolon), but it is not
  |
2 |    println!("Hello, world!");
  |                             ^

Being able to make suggestions which point to some lines in the source code but change it and label the changes would be a great feature, however, thinking of a good API to provide this will not be an easy task. Another thing i have considered is potentially exposing the renderer API to allow users to tack on their own render logic, which would help me immensely.

@brendanzab
Copy link
Owner

Yeah, this has been requested before (See #285)! Perhaps this is something we should have a look at.

For this specific instance, I'm wondering if using the notes section would help. Eg.

error: unknown start of token: \u{37e}
  ┌─ main.rs:2:30
  |
2 |    println!("Hello, world!");
  |                             ^
  = Unicode character ';' (Greek Question Mark) looks like ';' (Semicolon), but it is not

But I realise there are other instances where this is not as helpful, say with lifetime diagnostics, where you have to step through a sequence of related locations.

It would also be good to think about how this maps onto the language server protocol, but we might not want to limit ourselves by it. Eg. I tend to find lifetime errors easier to understand in the terminal, rather than using rust-analyzer.

@RDambrosio016
Copy link
Contributor Author

As with most pretty error stuff, the logic will be lost in the LSP, which is not necessarily bad, i agree with you in saying cli is way better for some errors, i dont think LSP should limit codespan when it comes to features. The example was the first i could think of, it is obviously very simplistic.

@Johann150
Copy link
Collaborator

I have not looked at the commits that were made, but maybe #176 could be interesting in this context?

@RDambrosio016
Copy link
Contributor Author

Allowing users to write their own render logic and plug into codespan's renderer would be infinitely helpful when it comes to more specific diagnostics

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants