XmlTextFormatter unexpected behavior

SyntaxEditor Web Languages Add-on for WPF Forum

Posted 2 years ago by Bodo R.
Version: 22.1.2
Platform: .NET 4.6
Environment: Windows 10 (64-bit)
Avatar

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 2 years ago]

Comments (2)

Posted 2 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

Thank you for the feedback, we will look into it.


Actipro Software Support

Posted 2 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Bodo,

We've refactored the XML text formatter for the next maintenance release v22.1.3 with improved logic.  The changes resolve these issues and others.


Actipro Software Support

The latest build of this product (v24.1.2) was released 1 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.