Fix an issue in module chasing caused by unnormalized file paths (#1303)

On Windows we can end up with rootModDir having / in the filepath
while rootPathDir uses \ so stripSuffix didn’t work.

This fixes #1284
This commit is contained in:
Moritz Kiefer 2019-05-22 13:58:22 +02:00 committed by mergify[bot]
parent a290aab694
commit 1fa783b876

View File

@ -233,7 +233,12 @@ runGhcSession IdeOptions{..} modu env act = runGhcEnv env $ do
moduleImportPaths :: GHC.ParsedModule -> Maybe FilePath
moduleImportPaths pm
| rootModDir == "." = Just rootPathDir
| otherwise = dropTrailingPathSeparator <$> stripSuffix rootModDir rootPathDir
| otherwise =
-- TODO (MK) stripSuffix (normalise rootModDir) (normalise rootPathDir)
-- would be a better choice but at the moment we do not consistently
-- normalize file paths in the Shake graph so we can end up with the
-- same module being represented twice in the Shake graph.
Just $ dropTrailingPathSeparator $ dropEnd (length rootModDir) rootPathDir
where
ms = GHC.pm_mod_summary pm
file = GHC.ms_hspp_file ms