Skip to content
Open
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
22 changes: 14 additions & 8 deletions plugins/hls-notes-plugin/src/Ide/Plugin/Notes.hs
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,13 @@ listReferences state _ param
Nothing -> pure (InR Null)
Just note -> do
notes <- runActionE "notes.definedNoteReferencess" state $ useE MkGetNoteReferences nfp
poss <- err ("Note reference (a comment of the form `{- Note [" <> note <> "] -}`) not found") (HM.lookup note notes)
pure $ InL (mapMaybe (\(noteFp, pos@(Position l' _)) -> if l' == l then Nothing else Just (
Location (fromNormalizedUri $ normalizedFilePathToUri noteFp) (Range pos pos))) poss)
case HM.lookup note notes of
Nothing -> pure (InR Null)
Just poss ->
pure $ InL (mapMaybe (\(noteFp, pos@(Position l' _)) ->
if l' == l then Nothing
else Just (Location (fromNormalizedUri $ normalizedFilePathToUri noteFp) (Range pos pos))
) poss)
where
uriOrig = toNormalizedUri $ param ^. (L.textDocument . L.uri)
listReferences _ _ _ = throwError $ PluginInternalError "conversion to normalized file path failed"
Expand All @@ -146,10 +150,12 @@ jumpToNote state _ param
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))
))
case HM.lookup note notes of
Nothing -> pure (InR (InR Null))
Just (noteFp, pos) ->
pure $ InL (Definition (InL
(Location (fromNormalizedUri $ normalizedFilePathToUri noteFp) (Range pos pos))
))
where
uriOrig = toNormalizedUri $ param ^. (L.textDocument . L.uri)
jumpToNote _ _ _ = throwError $ PluginInternalError "conversion to normalized file path failed"
Expand Down Expand Up @@ -194,4 +200,4 @@ noteRefRegex, noteRegex :: Regex
, mkReg ("note \\[([[:print:]]+)\\][[:blank:]]*\r?\n[[:blank:]]*(--)?[[:blank:]]*~~~" :: String)
)
where
mkReg = makeRegexOpts (defaultCompOpt { caseSensitive = False }) defaultExecOpt
mkReg = makeRegexOpts (defaultCompOpt { caseSensitive = False }) defaultExecOpt
Loading