@@ -49,7 +49,7 @@ import GHC (AddEpAnn (..), AnnContext (..), AnnParen (..),
4949 DeltaPos (SameLine ), EpAnn (.. ), EpaLocation (EpaDelta ),
5050 IsUnicodeSyntax (NormalSyntax ),
5151 NameAdornment (NameParens ), NameAnn (.. ), addAnns , ann , emptyComments ,
52- reAnnL , AnnList (.. ))
52+ reAnnL , AnnList (.. ), TrailingAnn ( AddCommaAnn ), addTrailingAnnToA )
5353#endif
5454import Language.LSP.Types
5555import Development.IDE.GHC.Util
@@ -490,11 +490,22 @@ extendImportViaParent df parent child (L l it@ImportDecl{..})
490490 -- we need change the ann key from `[]` to `:` to keep parens and other anns.
491491 unless hasSibling $
492492 transferAnn (L l' $ reverse pre) (L l' [x]) id
493+
494+ let lies' = reverse pre ++ [x]
493495#else
494- x :: LIE GhcPs = reLocA $ L l'' $ IEThingWith listAnn parentLIE NoIEWildcard [childLIE]
495496 listAnn = epAnn srcParent [AddEpAnn AnnOpenP (epl 1 ), AddEpAnn AnnCloseP (epl 0 )]
497+ x :: LIE GhcPs = reLocA $ L l'' $ IEThingWith listAnn parentLIE NoIEWildcard [childLIE]
498+
499+ x <- pure $ setEntryDP x (SameLine $ if (not (null pre)) then 1 else 0 )
500+
501+ let
502+
503+ fixLast = if not (null pre) then first addComma else id
504+ lies' = over _last fixLast lies ++ [x]
505+ lies = reverse pre
506+
496507#endif
497- return $ L l it{ideclHiding = Just (hide, L l' $ reverse pre ++ [x] )}
508+ return $ L l it{ideclHiding = Just (hide, L l' lies' )}
498509extendImportViaParent _ _ _ _ = lift $ Left " Unable to extend the import list via parent"
499510
500511unIEWrappedName :: IEWrappedName (IdP GhcPs ) -> String
0 commit comments