Skip to content

Conversation

@SATVIKsynopsis
Copy link

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.

Copy link
Collaborator

@jvanbruegge jvanbruegge left a comment

Choose a reason for hiding this comment

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

It is really hard to tell what the actual changes are here. Please do not do any reformatting in the same commit as you do functional changes. That is even ignoring that the changed formatting does not even pass the pre-commit hook from the project.

Please remove all reformatting from this PR, or at least split it into a separate commit

matchAllText noteRefRegex ln
where
atPos c arr = case arr A.! 0 of
-- We check if the line we are currently at contains a note
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why delete this comment?

mContents <- liftIO (runAction "notes.getfileContents" state (getFileContents nfp))
case mContents of
Nothing ->

Copy link
Collaborator

Choose a reason for hiding this comment

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

Why the extra newlines?

@SATVIKsynopsis
Copy link
Author

SATVIKsynopsis commented Dec 7, 2025

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.

@mati865
Copy link

mati865 commented Dec 7, 2025

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

@SATVIKsynopsis
Copy link
Author

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.

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.

hls-notes-plugin crashes instead of reporting no locations

3 participants