@@ -176,16 +176,21 @@ redundantImportTests = testGroup "redundant import code actions" [
176176 doc <- openDoc " src/CodeActionRedundant.hs" " haskell"
177177
178178 diags <- waitForDiagnosticsFromSource doc " typecheck"
179- liftIO $ expectDiagnostic diags [" The import of" , " Data.List" , " is redundant" ]
179+ liftIO $ expectDiagnostic diags [ " The import of" , " Data.List" , " is redundant" ]
180+ liftIO $ expectDiagnostic diags [ " Empty" , " from module" , " Data.Sequence" ]
180181
181182 mActions <- getAllCodeActions doc
182183
183184 let allActions = map fromAction mActions
184185 actionTitles = map (view L. title) allActions
185186
186- liftIO $ actionTitles `shouldContain` [" Remove import" , " Remove all redundant imports" ]
187+ liftIO $ actionTitles `shouldContain`
188+ [ " Remove import"
189+ , " Remove Empty from import"
190+ , " Remove all redundant imports"
191+ ]
187192
188- let mbRemoveAction = find (\ x -> x ^. L. title == " Remove import " ) allActions
193+ let mbRemoveAction = find (\ x -> x ^. L. title == " Remove all redundant imports " ) allActions
189194
190195 case mbRemoveAction of
191196 Just removeAction -> do
@@ -202,7 +207,17 @@ redundantImportTests = testGroup "redundant import code actions" [
202207 -- provides workspace edit property which skips round trip to
203208 -- the server
204209 contents <- documentContents doc
205- liftIO $ contents @?= " {-# OPTIONS_GHC -Wunused-imports #-}\n module CodeActionRedundant where\n main :: IO ()\n main = putStrLn \" hello\"\n "
210+ liftIO $ contents @?= T. unlines
211+ [ " {-# OPTIONS_GHC -Wunused-imports #-}"
212+ , " {-# LANGUAGE PatternSynonyms #-}"
213+ , " module CodeActionRedundant where"
214+ , " -- We need a non-reduntant import in the import list"
215+ , " -- to properly test the removal of the singular redundant item"
216+ , " import Data.Sequence (singleton)"
217+ , " main :: IO ()"
218+ , " main = putStrLn \" hello\" "
219+ , " where unused = Data.Sequence.singleton 42"
220+ ]
206221
207222 , testCase " doesn't touch other imports" $ runSession hlsCommand noLiteralCaps " test/testdata/redundantImportTest/" $ do
208223 doc <- openDoc " src/MultipleImports.hs" " haskell"
0 commit comments