@@ -176,16 +176,21 @@ redundantImportTests = testGroup "redundant import code actions" [
176
176
doc <- openDoc " src/CodeActionRedundant.hs" " haskell"
177
177
178
178
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" ]
180
181
181
182
mActions <- getAllCodeActions doc
182
183
183
184
let allActions = map fromAction mActions
184
185
actionTitles = map (view L. title) allActions
185
186
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
+ ]
187
192
188
- let mbRemoveAction = find (\ x -> x ^. L. title == " Remove import " ) allActions
193
+ let mbRemoveAction = find (\ x -> x ^. L. title == " Remove all redundant imports " ) allActions
189
194
190
195
case mbRemoveAction of
191
196
Just removeAction -> do
@@ -202,7 +207,17 @@ redundantImportTests = testGroup "redundant import code actions" [
202
207
-- provides workspace edit property which skips round trip to
203
208
-- the server
204
209
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
+ ]
206
221
207
222
, testCase " doesn't touch other imports" $ runSession hlsCommand noLiteralCaps " test/testdata/redundantImportTest/" $ do
208
223
doc <- openDoc " src/MultipleImports.hs" " haskell"
0 commit comments