@@ -17,7 +17,7 @@ module Development.IDE.GHC.Util(
17 prettyPrint,
17 prettyPrint,
18 runGhcEnv,
18 runGhcEnv,
19 textToStringBuffer,
19 textToStringBuffer,
20− moduleImportPaths,
20+ moduleImportPath,
21 HscEnvEq, hscEnv, newHscEnvEq
21 HscEnvEq, hscEnv, newHscEnvEq
@@ -103,16 +103,25 @@ fakeDynFlags = defaultDynFlags settings mempty
103 , pc_WORD_SIZE=8
103 , pc_WORD_SIZE=8
106−moduleImportPaths :: GHC.ParsedModule -> Maybe FilePath
106+moduleImportPath :: GHC.ParsedModule -> Maybe FilePath
107−moduleImportPaths pm
107+moduleImportPath pm
108− | rootModDir == "." = Just rootPathDir
108+ | rootModDir == "." = Just rootPathDir
109− | otherwise =
109+ | otherwise = do
110− dropTrailingPathSeparator <$> stripSuffix (normalise rootModDir) (normalise rootPathDir)
110+ dir <- dropTrailingPathSeparator <$> stripSuffix (normalise rootModDir) (normalise rootPathDir)
111+ -- For modules with more than one component, this can be empty, e.g.,
112+ -- stripSuffix (normalise ./A) (normalise ./A) for A/B.daml.
113+ -- We make a best effort attemp at not duplicating file paths
114+ -- by mapping the current directory to '.' if 'rootPathDir' starts with '.' and
115+ -- to an empty string otherwise.
116+ pure $! if null dir then dotDir else dir
118+ dotDir = if "." `isPrefixOf` rootPathDir then "." else ""
112 ms = GHC.pm_mod_summary pm
119 ms = GHC.pm_mod_summary pm
113 file = GHC.ms_hspp_file ms
120 file = GHC.ms_hspp_file ms
114 mod' = GHC.ms_mod ms
121 mod' = GHC.ms_mod ms
122+ -- ./src/A for file ./src/A/B.daml
115 rootPathDir = takeDirectory file
123 rootPathDir = takeDirectory file
116 rootModDir = takeDirectory . moduleNameSlashes . GHC.moduleName $ mod'
125 rootModDir = takeDirectory . moduleNameSlashes . GHC.moduleName $ mod'
118-- | An HscEnv with equality.
127-- | An HscEnv with equality.