@@ -69,6 +69,8 @@ import Development.IDE.Types.Shake (WithHieDb)
69
69
import HieDb hiding (pointCommand ,
70
70
withHieDb )
71
71
import System.Directory (doesFileExist )
72
+ import qualified Data.List as List
73
+ import System.FilePath
72
74
73
75
-- | Gives a Uri for the module, given the .hie file location and the the module info
74
76
-- The Bool denotes if it is a boot module
@@ -351,13 +353,32 @@ atPoint IdeOptions{} (HAR _ (hf :: HieASTs a) rf _ (kind :: HieKind hietype)) (D
351
353
= vcat (map renderEvidenceTree' xs)
352
354
renderEvidenceTree' (T. Node (EvidenceInfo {.. }) _)
353
355
= 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)
355
359
356
360
printDets :: RealSrcSpan -> Maybe (EvVarSource , Scope , Maybe Span ) -> SDoc
357
361
printDets _ Nothing = text " using an external instance"
358
362
printDets ospn (Just (src,_,mspn)) = pprSrc
359
- $$ text " at" <+> ppr spn
363
+ $$ text " at" <+> pprSrcSpanLink spn
360
364
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
361
382
-- Use the bind span if we have one, else use the occurrence span
362
383
spn = fromMaybe ospn mspn
363
384
pprSrc = case src of
0 commit comments