@@ -69,6 +69,8 @@ import Development.IDE.Types.Shake (WithHieDb)
6969import HieDb hiding (pointCommand ,
7070 withHieDb )
7171import System.Directory (doesFileExist )
72+ import qualified Data.List as List
73+ import System.FilePath
7274
7375-- | Gives a Uri for the module, given the .hie file location and the the module info
7476-- The Bool denotes if it is a boot module
@@ -351,13 +353,32 @@ atPoint IdeOptions{} (HAR _ (hf :: HieASTs a) rf _ (kind :: HieKind hietype)) (D
351353 = vcat (map renderEvidenceTree' xs)
352354 renderEvidenceTree' (T. Node (EvidenceInfo {.. }) _)
353355 = hang (text " - `" O. <> expandType evidenceType O. <> " `" ) 2 $
354- vcat $ printDets evidenceSpan evidenceDetails : map (text . T. unpack) (maybeToList $ definedAt evidenceVar)
356+ vcat $
357+ List. intersperse (text " " ) $
358+ printDets evidenceSpan evidenceDetails : map (text . T. unpack) (maybeToList $ definedAt evidenceVar)
355359
356360 printDets :: RealSrcSpan -> Maybe (EvVarSource , Scope , Maybe Span ) -> SDoc
357361 printDets _ Nothing = text " using an external instance"
358362 printDets ospn (Just (src,_,mspn)) = pprSrc
359- $$ text " at" <+> ppr spn
363+ $$ text " at" <+> pprSrcSpanLink spn
360364 where
365+ pprSrcSpanLink s =
366+ let
367+ -- Generate a source link for the srcspan according to the supported form:
368+ -- https://github.com/microsoft/vscode/blob/b3ec8181fc49f5462b5128f38e0723ae85e295c2/src/vs/platform/opener/common/opener.ts#L151-L160
369+ --
370+ -- This allows the link to be very accurate
371+ fp = normalise $ Util. unpackFS $ srcSpanFile s
372+ startLine = srcLocLine $ realSrcSpanStart s
373+ startCol = srcLocCol $ realSrcSpanStart s
374+ endLine = srcLocLine $ realSrcSpanEnd s
375+ endCol = srcLocCol $ realSrcSpanEnd s
376+ srcRangeText =
377+ " L" <> show startLine <> " ," <> show startCol
378+ <> " -L" <> show endLine <> " ," <> show endCol
379+ srcLink = text " file://" O. <> text fp O. <> " #" O. <> text srcRangeText
380+ in
381+ O. brackets (text (takeFileName fp) O. <> " :" O. <> ppr startLine) O. <> O. parens srcLink
361382 -- Use the bind span if we have one, else use the occurrence span
362383 spn = fromMaybe ospn mspn
363384 pprSrc = case src of
0 commit comments