haskell-language-server icon indicating copy to clipboard operation
haskell-language-server copied to clipboard

Fix notes plugin: avoid crashes on missing note definitions and improve lookup handling

Open SATVIKsynopsis opened this issue 1 month ago • 5 comments

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:

  1. Graceful handling of missing notes in jump-to-definition and references.

  2. Replacing unsafe lookups with fromMaybe.

  3. Cleaning up unused imports.

Functionality tested with a simple example; jump-to-definition works correctly and missing notes no longer cause errors.

SATVIKsynopsis avatar Dec 06 '25 19:12 SATVIKsynopsis

Thanks for the feedback

  1. I have updated the listReferences and jumpToNote handlers as requested

  2. Removed the previous err-based handling for missing notes and references.

  3. Added explicit case HM.lookup branches to return Null when the note or reference is not found.

  4. Ensured both handlers now match the behavior of “Goto Definition” when no match exists.

  5. No unrelated logic or formatting was changed.

Please let me know if anything else should be adjusted.

SATVIKsynopsis avatar Dec 07 '25 08:12 SATVIKsynopsis

@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.

mati865 avatar Dec 07 '25 12:12 mati865

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.

SATVIKsynopsis avatar Dec 07 '25 13:12 SATVIKsynopsis

The code looks now fine, but the pre-commit hook needs to pass and it should have a test for the new empty responses

jvanbruegge avatar Dec 09 '25 11:12 jvanbruegge

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.

SATVIKsynopsis avatar Dec 09 '25 11:12 SATVIKsynopsis