microsoft / microsoft/XmlNotepad

Preserve empty-element formatting across versions

Open
#500 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
1.2k
Forks
240
PR merge metrics
No merged PRs in 30d

Description

Image

Description

When editing XML files with XmlNotepad and using Auto Format on Save, the representation of empty elements may change between versions.

For example, an empty element originally written as:

<Read Key="x" />

may be rewritten as:

<Read Key="x"></Read>

Both forms are semantically equivalent XML, so this is not a functional issue. However, it creates unnecessary noise in source control systems such as Git, especially in repositories where XML files are frequently reviewed and compared.

Expected behavior

When Auto Format on Save is enabled, XmlNotepad should preserve a consistent representation of empty elements.

Possible approaches:

  • Preserve the original style already present in the document.

  • Provide a formatting option allowing users to choose between:

    • Self-closing tags (<Tag />)
    • Explicit opening/closing tags (<Tag></Tag>)
  • At minimum, avoid changing the formatting style between XmlNotepad versions.

Actual behavior

After upgrading XmlNotepad, saving an XML document may rewrite empty elements using a different representation than previous versions, generating large diffs with no semantic changes.

Why this matters

In environments where XML files are stored in Git:

  • Reviews become harder because diffs contain formatting-only changes.
  • Merges may become noisier.
  • Upgrading the editor can unexpectedly modify many files.

The formatting style itself is not important; consistency is.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the behavior in XmlNotepad by enabling Auto Format on Save and saving XML containing an empty element in both supported representations. Trace the save-formatting path from that reproduction and determine how the current version chooses the representation. Done means repeated saves and upgrades do not introduce inconsistent empty-element formatting, with behavior covered by an appropriate regression test if the project provides one.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
desktop
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.