File tree Expand file tree Collapse file tree 4 files changed +107
-26
lines changed
Fantomas.Core.Tests/Stroustrup Expand file tree Collapse file tree 4 files changed +107
-26
lines changed Original file line number Diff line number Diff line change 11# Changelog
22
3+ ## 6.3.4 - 2024-04-16
4+
5+ ### Fixed
6+ * Regression: An empty line or comment at the end of a list breaks Stroustrup formatting. [ #3079 ] ( https://github.com/fsprojects/fantomas/issues/3079 )
7+
38## 6.3.3 - 2024-04-12
49
510### Fixed
Original file line number Diff line number Diff line change @@ -95,31 +95,6 @@ let x y = [
9595]
9696"""
9797
98- [<Test>]
99- let ``hash directive before closing list bracket , 3070`` () =
100- formatSourceString
101- """
102- let private knownProviders = [
103- #if !FABLE_COMPILER
104- (SerilogProvider.isAvailable, SerilogProvider.create)
105- (MicrosoftExtensionsLoggingProvider.isAvailable, MicrosoftExtensionsLoggingProvider.create)
106- #endif
107- ]
108- """
109- config
110- |> prepend newline
111- |> should
112- equal
113- """
114- let private knownProviders =
115- [
116- #if !FABLE_COMPILER
117- (SerilogProvider.isAvailable, SerilogProvider.create)
118- (MicrosoftExtensionsLoggingProvider.isAvailable, MicrosoftExtensionsLoggingProvider.create)
119- #endif
120- ]
121- """
122-
12398[<Test>]
12499let ``hash directive before closing list bracket , nested let binding`` () =
125100 formatSourceString
Original file line number Diff line number Diff line change @@ -736,3 +736,99 @@ let b = // Build an inbound for the specified subnet.
736736 Tags = Map.empty
737737 }
738738"""
739+
740+ [<Test>]
741+ let ``hash directive before closing list bracket , 3070`` () =
742+ formatSourceString
743+ """
744+ let private knownProviders = [
745+ #if !FABLE_COMPILER
746+ (SerilogProvider.isAvailable, SerilogProvider.create)
747+ (MicrosoftExtensionsLoggingProvider.isAvailable, MicrosoftExtensionsLoggingProvider.create)
748+ #endif
749+ ]
750+ """
751+ config
752+ |> prepend newline
753+ |> should
754+ equal
755+ """
756+ let private knownProviders =
757+ [
758+ #if !FABLE_COMPILER
759+ (SerilogProvider.isAvailable, SerilogProvider.create)
760+ (MicrosoftExtensionsLoggingProvider.isAvailable, MicrosoftExtensionsLoggingProvider.create)
761+ #endif
762+ ]
763+ """
764+
765+ [<Test>]
766+ let ``empty line before closing list bracket , 3079`` () =
767+ formatSourceString
768+ """
769+ let list = [
770+ someItem
771+
772+ ]
773+ """
774+ config
775+ |> prepend newline
776+ |> should
777+ equal
778+ """
779+ let list = [
780+ someItem
781+
782+ ]
783+ """
784+
785+ [<Test>]
786+ let ``comment before closing list bracket , 3079`` () =
787+ formatSourceString
788+ """
789+ let list = [
790+ someItem
791+ // comment
792+ ]
793+ """
794+ config
795+ |> prepend newline
796+ |> should
797+ equal
798+ """
799+ let list = [
800+ someItem
801+ // comment
802+ ]
803+ """
804+
805+ [<Test>]
806+ let ``comment before closing list bracket with hash directive`` () =
807+ formatSourceString
808+ """
809+ let list = [
810+ someItem
811+ #if something
812+ item1
813+ #else
814+ item2
815+ #endif
816+ // comment
817+ ]
818+ """
819+ config
820+ |> prepend newline
821+ |> should
822+ equal
823+ """
824+ let list =
825+ [
826+ someItem
827+ #if something
828+ item1
829+ #else
830+ item2
831+ #endif
832+ // comment
833+ ]
834+ """
Original file line number Diff line number Diff line change @@ -938,7 +938,12 @@ let indentSepNlnUnindentUnlessStroustrup f (e: Expr) (ctx: Context) =
938938 let shouldUseStroustrup =
939939 let isArrayOrListWithHashDirectiveBeforeClosingBracket () =
940940 match e with
941- | Expr.ArrayOrList node -> Seq.isEmpty node.Closing.ContentBefore
941+ | Expr.ArrayOrList node ->
942+ node.Closing.ContentBefore
943+ |> Seq.forall ( fun x ->
944+ match x.Content with
945+ | TriviaContent.Directive _ -> false
946+ | _ -> true )
942947 | _ -> true
943948
944949 isStroustrupStyleExpr ctx.Config e
You can’t perform that action at this time.
0 commit comments