@@ -49,7 +49,7 @@ import GHC (AddEpAnn (..), AnnContext (..), AnnParen (..),
49
49
DeltaPos (SameLine ), EpAnn (.. ), EpaLocation (EpaDelta ),
50
50
IsUnicodeSyntax (NormalSyntax ),
51
51
NameAdornment (NameParens ), NameAnn (.. ), addAnns , ann , emptyComments ,
52
- reAnnL , AnnList (.. ))
52
+ reAnnL , AnnList (.. ), TrailingAnn ( AddCommaAnn ), addTrailingAnnToA )
53
53
#endif
54
54
import Language.LSP.Types
55
55
import Development.IDE.GHC.Util
@@ -490,11 +490,22 @@ extendImportViaParent df parent child (L l it@ImportDecl{..})
490
490
-- we need change the ann key from `[]` to `:` to keep parens and other anns.
491
491
unless hasSibling $
492
492
transferAnn (L l' $ reverse pre) (L l' [x]) id
493
+
494
+ let lies' = reverse pre ++ [x]
493
495
#else
494
- x :: LIE GhcPs = reLocA $ L l'' $ IEThingWith listAnn parentLIE NoIEWildcard [childLIE]
495
496
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
+
496
507
#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' )}
498
509
extendImportViaParent _ _ _ _ = lift $ Left " Unable to extend the import list via parent"
499
510
500
511
unIEWrappedName :: IEWrappedName (IdP GhcPs ) -> String
0 commit comments