@@ -118,7 +118,7 @@ lensProvider
118118 -- haskell-lsp provides conversion functions
119119 | Just nfp <- uriToNormalizedFilePath $ toNormalizedUri _uri = liftIO $
120120 do
121- mbMinImports <- runAction " " state $ useWithStale MinimalImports nfp
121+ mbMinImports <- runAction " MinimalImports " state $ useWithStale MinimalImports nfp
122122 case mbMinImports of
123123 -- Implement the provider logic:
124124 -- for every import, if it's lacking a explicit list, generate a code lens
@@ -212,13 +212,23 @@ minimalImportsRule recorder = define (cmapWithPrio LogShake recorder) $ \Minimal
212212 Map. fromList
213213 [ (realSrcSpanStart l, printOutputable i)
214214 | L (locA -> RealSrcSpan l _) i <- fromMaybe [] mbMinImports
215+ , not (isImplicitPrelude i)
215216 ]
216217 res =
217218 [ (i, Map. lookup (realSrcSpanStart l) importsMap)
218219 | i <- imports
219220 , RealSrcSpan l _ <- [getLoc i]
220221 ]
221222 return ([] , MinimalImportsResult res <$ mbMinImports)
223+ where
224+ isImplicitPrelude :: (Outputable a ) => a -> Bool
225+ isImplicitPrelude importDecl =
226+ T. isPrefixOf implicitPreludeImportPrefix (printOutputable importDecl)
227+
228+ -- | This is the prefix of an implicit prelude import which should be ignored,
229+ -- when considering the minimal imports rule
230+ implicitPreludeImportPrefix :: T. Text
231+ implicitPreludeImportPrefix = " import (implicit) Prelude"
222232
223233--------------------------------------------------------------------------------
224234
0 commit comments