
Hi,
when using the XMLTextFormatter with ElementSpacingMode set to XmlElementSpacingMode.RemoveEmptyLines the result is partly strange.
1. Empty lines before comments persist (line after Tag1 will not be deleted)
<Root>
<Tag1></Tag1>
<!-- comment -->
<Tag></Tag>
</Root>
2. the Formatter INSERTS empty lines when an comment is the last element before closing root
before Format
<Root>
<Tag1></Tag1>
<Tag></Tag>
<!-- comment -->
</Root>
after Format -- more calls of Format ... more empty lines
<Root>
<Tag1></Tag1>
<Tag></Tag>
<!-- comment -->
</Root>
3. comments are not moved to a new line (comment stays in line after Tag1)
<Root>
<Tag1></Tag1><!-- comment -->
<Tag></Tag>
</Root>
4. comments with own line are shifted to position 1 and not aligned with surrounding tags
before Format
<Root>
<Tag1></Tag1>
<!-- comment -->
<Tag></Tag>
</Root>
after Format
<Root>
<Tag1></Tag1>
<!-- comment -->
<Tag></Tag>
</Root>
Edit:
No need for programming to reproduce... just play with the sample
SyntaxEditor -> Web Languages Add-On QuickStarts ->XML Text Formatter Options
EndEdit
You can reproduce this by adding follwing lines in the SyntaxEditorSamples\Demo\WebAddonXmlEditor\MainControl.xaml.cs at the MainControl() function after the RegisterXmlSchemaResolver(..) call.
var Formatter = xmlEditor.Document.Language.GetTextFormatter() as XmlTextFormatter;
Formatter.ElementSpacingMode = XmlElementSpacingMode.RemoveEmptyLines;
Then play around with the XML in editor window.
---------------------------
Kind Regards
Bodo
[Modified 3 years ago]