@@ -778,6 +778,7 @@ codeActionTests = testGroup "code actions"
778778 , suggestHideShadowTests
779779 , suggestImportDisambiguationTests
780780 , fixConstructorImportTests
781+ , fixModuleImportTypoTests
781782 , importRenameActionTests
782783 , fillTypedHoleTests
783784 , addSigActionTests
@@ -1804,6 +1805,31 @@ extendImportTests = testGroup "extend import actions"
18041805 contentAfterAction <- documentContents docB
18051806 liftIO $ expectedContentB @=? contentAfterAction
18061807
1808+ fixModuleImportTypoTests :: TestTree
1809+ fixModuleImportTypoTests = testGroup " fix module import typo"
1810+ [ testSession " works when single module suggested" $ do
1811+ doc <- createDoc " A.hs" " haskell" " import Data.Cha"
1812+ _ <- waitForDiagnostics
1813+ InR action@ CodeAction { _title = actionTitle } : _ <- getCodeActions doc (R 0 0 0 10 )
1814+ liftIO $ actionTitle @?= " replace with Data.Char"
1815+ executeCodeAction action
1816+ contentAfterAction <- documentContents doc
1817+ liftIO $ contentAfterAction @?= " import Data.Char"
1818+ , testSession " works when multiple modules suggested" $ do
1819+ doc <- createDoc " A.hs" " haskell" " import Data.I"
1820+ _ <- waitForDiagnostics
1821+ actions <- sortOn (\ (InR CodeAction {_title= x}) -> x) <$> getCodeActions doc (R 0 0 0 10 )
1822+ let actionTitles = [ title | InR CodeAction {_title= title} <- actions ]
1823+ liftIO $ actionTitles @?= [ " replace with Data.Eq"
1824+ , " replace with Data.Int"
1825+ , " replace with Data.Ix"
1826+ ]
1827+ let InR replaceWithDataEq : _ = actions
1828+ executeCodeAction replaceWithDataEq
1829+ contentAfterAction <- documentContents doc
1830+ liftIO $ contentAfterAction @?= " import Data.Eq"
1831+ ]
1832+
18071833extendImportTestsRegEx :: TestTree
18081834extendImportTestsRegEx = testGroup " regex parsing"
18091835 [
0 commit comments