File tree Expand file tree Collapse file tree 5 files changed +43
-3
lines changed
CSharpier.Tests/FormattingTests/TestFiles/xml Expand file tree Collapse file tree 5 files changed +43
-3
lines changed Original file line number Diff line number Diff line change 11using System . Buffers ;
22using System . Diagnostics ;
33using System . Runtime . CompilerServices ;
4+ using System . Text . Json ;
45
56namespace CSharpier . Core . Utilities ;
67
@@ -176,4 +177,10 @@ private void Grow(int additionalCapacityRequired = 1)
176177 ArrayPool < T > . Shared . Return ( toReturn ) ;
177178 }
178179 }
180+
181+ public override string ToString ( )
182+ {
183+ // TODO get this to actually show something useful
184+ return JsonSerializer . Serialize ( this . ToArray ( ) ) ;
185+ }
179186}
Original file line number Diff line number Diff line change @@ -66,6 +66,15 @@ Doc PrintLineAfterChildren()
6666 {
6767 return Doc . Null ;
6868 }
69+
70+ if (
71+ rawNode . Nodes is [ { NodeType : XmlNodeType . Text } ]
72+ && rawNode . Nodes [ 0 ] . Value . Contains ( '\n ' )
73+ )
74+ {
75+ return Doc . Null ;
76+ }
77+
6978 return Doc . SoftLine ;
7079 }
7180
Original file line number Diff line number Diff line change @@ -126,9 +126,31 @@ private static bool NeedsToBorrowParentClosingTagStartMarker(RawNode rawNode)
126126 * ^^^
127127 * >
128128 */
129+ // TODO #1789 we really want this last condition only if the indentation of the last line of the text value matches
130+ // the indentation of the start element. Bleh.
131+ /*
132+ may have to handle one of these vs the second
133+ <Root>
134+ <Element Attribute="TheSign">
135+ Life is demanding.
136+ </Element>
137+ </Root>
138+ <Root>
139+ <Element Attribute="TheSign">
140+ Life is demanding.
141+ </Element>
142+ </Root>
143+ there is also this case
144+ <Root>
145+ <Element >
146+ Life is demanding.
147+ </Element>
148+ </Root>
149+ */
129150 return rawNode . NextNode is null
130151 && rawNode . IsTextLike ( )
131- && rawNode . GetLastDescendant ( ) . NodeType is XmlNodeType . Text ;
152+ && rawNode . GetLastDescendant ( ) is { NodeType : XmlNodeType . Text } textNode
153+ && ! textNode . Value . Contains ( '\n ' ) ;
132154 }
133155
134156 public static bool NeedsToBorrowParentOpeningTagEndMarker ( RawNode rawNode )
Original file line number Diff line number Diff line change 1111 AND '$(MSBuildProjectName)' != 'System.Net.Http.Formatting.NetCore.Test'
1212 AND '$(MSBuildProjectName)' != 'System.Net.Http.Formatting.NetStandard.Test' "
1313 />
14+ <Element Attribute="TheSign">
15+ Life is demanding.
16+ </Element>
1417</Root>
Original file line number Diff line number Diff line change 33
44 Because whitespace is strict
55 The indentation of the closing element can't change
6- </Element
7- >
6+ </Element>
87 <Element>
98 Shorter Text with indentation that can't change
109 </Element>
You can’t perform that action at this time.
0 commit comments