Fix notes plugin: avoid crashes on missing note definitions and improve lookup handling
Fixes #4763
This PR updates the Notes plugin to safely handle cases where note definitions or references are missing.
So, Instead of throwing internal errors, the plugin now returns Null results as expected by the LSP specs.
Changes include:
-
Graceful handling of missing notes in jump-to-definition and references.
-
Replacing unsafe lookups with
fromMaybe. -
Cleaning up unused imports.
Functionality tested with a simple example; jump-to-definition works correctly and missing notes no longer cause errors.
Thanks for the feedback
-
I have updated the
listReferencesandjumpToNotehandlers as requested -
Removed the previous err-based handling for missing notes and references.
-
Added explicit case
HM.lookupbranches to returnNullwhen the note or reference is not found. -
Ensured both handlers now match the behavior of
“Goto Definition”when no match exists. -
No unrelated logic or formatting was changed.
Please let me know if anything else should be adjusted.
@jvanbruegge a heads-up, it might be hard to review this PR because this is at least largely a chatbot's work. You can see similar pull requests to other projects on author's profile.
To clarify, I reviewed the changes myself before submitting the PR. If anything looks off or needs adjustment I am m happy to revise it. Please let me know what should be improved.
The code looks now fine, but the pre-commit hook needs to pass and it should have a test for the new empty responses
Thanks for the review
I am currently focusing on Rust contributions and I no longer have the Haskell setup locally. Because of this, I won’t be able to continue this PR right now.
Feel free to close it or let someone else pick it up. I learned from the review and appreciate your time.