Skip to content
This repository was archived by the owner on Jan 2, 2021. It is now read-only.

Fix docs tooltip for base libraries on Windows #814

Merged
merged 5 commits into from
Sep 20, 2020
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
12 changes: 9 additions & 3 deletions src/Development/IDE/Spans/Documentation.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ module Development.IDE.Spans.Documentation (
) where

import Control.Monad
import Control.Monad.Extra (findM)
import Data.Foldable
import Data.List.Extra
import qualified Data.Map as M
Expand Down Expand Up @@ -172,8 +173,10 @@ lookupHtmlForModule :: (FilePath -> FilePath -> FilePath) -> DynFlags -> Module
lookupHtmlForModule mkDocPath df m = do
-- try all directories
let mfs = fmap (concatMap go) (lookupHtmls df ui)
htmls <- filterM doesFileExist (concat . maybeToList $ mfs)
return $ listToMaybe htmls
html <- findM doesFileExist (concat . maybeToList $ mfs)
-- canonicalize located html to remove /../ indirection which can break some clients
-- (vscode on Windows at least)
traverse canonicalizePath html
where
go pkgDocDir = map (mkDocPath pkgDocDir) mns
ui = moduleUnitId m
Expand All @@ -186,4 +189,7 @@ lookupHtmlForModule mkDocPath df m = do
map (`intercalate` chunks) [".", "-"]

lookupHtmls :: DynFlags -> UnitId -> Maybe [FilePath]
lookupHtmls df ui = haddockHTMLs <$> lookupPackage df ui
lookupHtmls df ui =
-- use haddockInterfaces instead of haddockHTMLs: GHC treats haddockHTMLs as URL not path
-- and therefore doesn't expand $topdir on Windows
map takeDirectory . haddockInterfaces <$> lookupPackage df ui