on master help sign in
Feedback from PR to improve import path finding (#1188)

* Feedback from PR to improve import path finding * Update compiler/haskell-ide-core/src/Development/IDE/Functions/Compile.hs

commit749ee7d6994be71e936fa8032a6db6d76a685eaa authorNeil Mitchell <35463327+neil-da@users.noreply.github.com> dateThu 16 May 2019, 15:14 (7 years ago) parent718e338
1 file changed+6−7
src/Development/IDE/Functions/Compile.hs+6−7
src/Development/IDE/Functions/Compile.hs+6−7
@@ -241,22 +241,21 @@ runGhcSession
241241 -> Ghc a
242242 -> IO a
243243runGhcSession IdeOptions{..} modu env act = runGhcEnv env $ do
244− modifyDynFlags $ \x -> x{importPaths = maybe [] moduleImportPaths modu ++ importPaths x}
244+ modifyDynFlags $ \x -> x
245+ {importPaths = nubOrd $ maybeToList (moduleImportPaths =<< modu) ++ importPaths x}
245246 act
246247
247248
248−moduleImportPaths :: GHC.ParsedModule -> [FilePath]
249−moduleImportPaths pm =
250− maybe [] (\modRoot -> [modRoot]) mbModuleRoot
249+moduleImportPaths :: GHC.ParsedModule -> Maybe FilePath
250+moduleImportPaths pm
251+ | rootModDir == "." = Just rootPathDir
252+ | otherwise = dropTrailingPathSeparator <$> stripSuffix rootModDir rootPathDir
251253 where
252254 ms = GHC.pm_mod_summary pm
253255 file = GHC.ms_hspp_file ms
254256 mod' = GHC.ms_mod ms
255257 rootPathDir = takeDirectory file
256258 rootModDir = takeDirectory . moduleNameSlashes . GHC.moduleName $ mod'
257− mbModuleRoot
258− | rootModDir == "." = Just rootPathDir
259− | otherwise = dropTrailingPathSeparator <$> stripSuffix rootModDir rootPathDir
260259
261260
262261-- When we make a fresh GHC environment, the OrigNameCache comes already partially