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

Commit 20ce9d3

Browse files
DunetsNMpepeiborra
andauthored
Fix docs tooltip for base libraries on Windows (#814)
* Prepare for release 0.4.0 * lookup haddock dir via haddockInterfaces * Fix broken base libraries documentation on Windows * use findM to get just first existing file Co-authored-by: Pepe Iborra <[email protected]>
1 parent 1d1f2db commit 20ce9d3

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/Development/IDE/Spans/Documentation.hs

+9-3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ module Development.IDE.Spans.Documentation (
1212
) where
1313

1414
import Control.Monad
15+
import Control.Monad.Extra (findM)
1516
import Data.Foldable
1617
import Data.List.Extra
1718
import qualified Data.Map as M
@@ -172,8 +173,10 @@ lookupHtmlForModule :: (FilePath -> FilePath -> FilePath) -> DynFlags -> Module
172173
lookupHtmlForModule mkDocPath df m = do
173174
-- try all directories
174175
let mfs = fmap (concatMap go) (lookupHtmls df ui)
175-
htmls <- filterM doesFileExist (concat . maybeToList $ mfs)
176-
return $ listToMaybe htmls
176+
html <- findM doesFileExist (concat . maybeToList $ mfs)
177+
-- canonicalize located html to remove /../ indirection which can break some clients
178+
-- (vscode on Windows at least)
179+
traverse canonicalizePath html
177180
where
178181
go pkgDocDir = map (mkDocPath pkgDocDir) mns
179182
ui = moduleUnitId m
@@ -186,4 +189,7 @@ lookupHtmlForModule mkDocPath df m = do
186189
map (`intercalate` chunks) [".", "-"]
187190

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

0 commit comments

Comments
 (0)