haskell / haskell-ide-engine

The engine for haskell ide-integration. Not an IDE
BSD 3-Clause "New" or "Revised" License
2.38k stars 213 forks source link

Bug: lookupHtmlForModule failes when generated haddock HTML file is seperated by dots #1722

Closed louwers closed 4 years ago

louwers commented 4 years ago

The lookupHtmlForModule function in src/Haskell/Ide/Engine/Plugin/Haddock.hs fails to find the source HTML document when the path if formatted with dots instead of dashes.

lookupHtmlForModule mkDocPath df m = do
  let mfp = go <$> (listToMaybe =<< lookupHtmls df ui)
  exists <- maybe (pure False) doesFileExist mfp
  return $ if exists then mfp else Nothing
  where
    go pkgDocDir = mkDocPath pkgDocDir mn
    ui = moduleUnitId m
    mn = map (\x -> if x == '.' then '-' else x) mns
    mns = moduleNameString $ moduleName m

E.g. it can find the documentation HTML here: /home/bart/.stack/snapshots/x86_64-linux-tinfo6/....../8.6.5/doc/hakyll-4.13.0.1/Hakyll-Core-Rules.html

But it cannot find the source HTML here: /home/bart/.stack/snapshots/x86_64-linux-tinfo6/...../8.6.5/doc/hakyll-4.13.0.1/src/Hakyll.Core.Rules.html

The implementor on the IRC said:

A simple fix would be to check for both versions of the file, with the '.' and with '-', and simply return whichever one exists on disk