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

Prevent panic when receiving malformed LSP PublishDiagnostic #2160

Conversation

the-mikedavis
Copy link
Member

Instead of panicing we can discard the malformed diagnostic. This
.parse() fails commonly when a non-conformant language server gives
a diagnostic with a location that breaks the spec:

{ "character": 0, "line": -1 }

can currently be returned by ElixirLS and the python LS. Other
messages in this block are discarded but this one feels special enough
to log. Maybe we should refactor all parses to log errors in cases of
malformed messages?

closes #1204

Instead of panicing we can discard the malformed diagnostic. This
`.parse()` fails commonly when a non-conformant language server gives
a diagnostic with a location that breaks the spec:

    { "character": 0, "line": -1 }

can currently be returned by ElixirLS and the python LS. Other
messages in this block are discarded but this one feels special enough
to log.
@the-mikedavis the-mikedavis changed the title prevent panic when receiving malformed LSP PublishDiagnostic Prevent panic when receiving malformed LSP PublishDiagnostic Apr 18, 2022
Copy link
Contributor

@pickfire pickfire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe I also got similar error in rust, but at least it didn't panic, I think this should solve the issue I guess.

@pickfire pickfire merged commit 449d1df into helix-editor:master Apr 18, 2022
@the-mikedavis the-mikedavis deleted the md-malformed-diagnostic-prevent-panic branch April 18, 2022 15:11
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

Successfully merging this pull request may close these issues.

Panicked on macOS Catalina when editing python code
2 participants