Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions plugins/hls-notes-plugin/src/Ide/Plugin/Notes.hs
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,15 @@ jumpToNote state _ param
=<< lift (LSP.getVirtualFile uriOrig)
line <- err "Line not found in file" (listToMaybe $ Rope.lines $ fst
(Rope.splitAtLine 1 $ snd $ Rope.splitAtLine (fromIntegral l) contents))
note <- err "No note at this position" $ listToMaybe $
mapMaybe (atPos $ fromIntegral c) $ matchAllText noteRefRegex line
notes <- runActionE "notes.definedNotes" state $ useE MkGetNotes nfp
(noteFp, pos) <- err ("Note definition (a comment of the form `{- Note [" <> note <> "]\\n~~~ ... -}`) not found") (HM.lookup note notes)
pure $ InL (Definition (InL
(Location (fromNormalizedUri $ normalizedFilePathToUri noteFp) (Range pos pos))
))
let noteOpt = listToMaybe $ mapMaybe (atPos $ fromIntegral c) $ matchAllText noteRefRegex line
case noteOpt of
Nothing -> pure (InR (InR Null))
Just note -> do
notes <- runActionE "notes.definedNotes" state $ useE MkGetNotes nfp
(noteFp, pos) <- err ("Note definition (a comment of the form `{- Note [" <> note <> "]\\n~~~ ... -}`) not found") (HM.lookup note notes)
pure $ InL (Definition (InL
(Location (fromNormalizedUri $ normalizedFilePathToUri noteFp) (Range pos pos))
))
where
uriOrig = toNormalizedUri $ param ^. (L.textDocument . L.uri)
err s = maybe (throwError $ PluginInternalError s) pure
Expand Down