@@ -778,6 +778,7 @@ codeActionTests = testGroup "code actions"
778
778
, suggestHideShadowTests
779
779
, suggestImportDisambiguationTests
780
780
, fixConstructorImportTests
781
+ , fixModuleImportTypoTests
781
782
, importRenameActionTests
782
783
, fillTypedHoleTests
783
784
, addSigActionTests
@@ -1804,6 +1805,31 @@ extendImportTests = testGroup "extend import actions"
1804
1805
contentAfterAction <- documentContents docB
1805
1806
liftIO $ expectedContentB @=? contentAfterAction
1806
1807
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
+
1807
1833
extendImportTestsRegEx :: TestTree
1808
1834
extendImportTestsRegEx = testGroup " regex parsing"
1809
1835
[
0 commit comments