@@ -311,7 +311,7 @@ suggestExportUnusedTopBinding srcOpt ParsedModule{pm_parsed_source = L _ HsModul
311
311
$ hsmodDecls
312
312
, Just pos <- _end . getLocatedRange <$> hsmodExports
313
313
, Just needComma <- needsComma source <$> hsmodExports
314
- , let exportName = (if needComma then " ," else " " ) <> printExport exportType name
314
+ , let exportName = (if needComma then " ," else " " ) <> printExport exportType name
315
315
insertPos = pos {_character = pred $ _character pos}
316
316
= [(" Export ‘" <> name <> " ’" , [TextEdit (Range insertPos insertPos) exportName])]
317
317
| otherwise = []
@@ -833,19 +833,24 @@ suggestNewImport _ _ _ = []
833
833
constructNewImportSuggestions
834
834
:: PackageExportsMap -> NotInScope -> Maybe [T. Text ] -> [T. Text ]
835
835
constructNewImportSuggestions exportsMap thingMissing notTheseModules = nubOrd
836
- [ renderNewImport identInfo m
836
+ [ suggestion
837
837
| (identInfo, m) <- fromMaybe [] $ Map. lookup name exportsMap
838
838
, canUseIdent thingMissing identInfo
839
839
, m `notElem` fromMaybe [] notTheseModules
840
+ , suggestion <- renderNewImport identInfo m
840
841
]
841
842
where
842
843
renderNewImport identInfo m
843
- | Just q <- qual = " import qualified " <> m <> " as " <> q
844
- | otherwise = " import " <> m <> " (" <> importWhat identInfo <> " )"
844
+ | Just q <- qual
845
+ , asQ <- if q == m then " " else " as " <> q
846
+ = [" import qualified " <> m <> asQ]
847
+ | otherwise
848
+ = [" import " <> m <> " (" <> importWhat identInfo <> " )"
849
+ ," import " <> m ]
845
850
846
851
(qual, name) = case T. splitOn " ." (notInScope thingMissing) of
847
852
[n] -> (Nothing , n)
848
- segments -> (Just (T. concat $ init segments), last segments)
853
+ segments -> (Just (T. intercalate " . " $ init segments), last segments)
849
854
importWhat IdentInfo {parent, rendered}
850
855
| Just p <- parent = p <> " (" <> rendered <> " )"
851
856
| otherwise = rendered
0 commit comments