redhat-developer / redhat-developer/vscode-xml
XML formatter produces inconsistent line wrapping and indentation
@angelozerr is already working on this.
Since Sep 10, 2026.
- Dominant language
- TypeScript
- Stars
- 328
- Forks
- 101
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 7
Description
The current XML formatting functionality produces inconsistent results, for example, when processing MyBatis mapper files. Specifically, the formatter treats elements with nearly identical character lengths differently without a clear logical basis. For example, the tag for "username" remains on a single line, whereas the tag for "password"—which has the same character length and structure—is forced into a line break with erratic indentation. This creates a staggered, "zigzag" visual effect that significantly degrades code readability.
The desired behavior is a standardized formatting style similar to that of the prettier-xml plugin. Regardless of the element's length, the formatter should apply consistent indentation to both XML elements and their nested text content. Each logical SQL segment should be cleanly separated, and tags like and should maintain a clear hierarchy rather than being collapsed into a single line. This consistency is crucial for maintaining large mapper files and performing clean code reviews.
Current Inconsistent Formatting:
<update id="updateEmp"> update emp <set>
<if test="username != null and username != ''">username=#{username},</if>
<if test="password != null and password != ''">
password=#{password},</if>
<if test="name != null and name != ''">name=#{name},</if>
<if test="gender != null">
gender=#{gender},</if>
<if test="phone != null and phone != ''">phone=#{phone},</if>
<if test="job != null">
job=#{job},</if>
<if test="salary != null">salary=#{salary},</if>
<if test="image != null and image != ''">
image=#{image},</if>
<if test="entryDate != null">entry_date=#{entryDate},</if>
<if test="deptId != null">
dept_id=#{deptId},</if> update_time=#{updateTime} </set> where id=#{id} </update>
</mapper>
Expected Formatting (Prettier-style, just an example):
<update id="updateEmp">
UPDATE emp
<set>
<if test="username != null and username != ''">username = #{username},</if>
<if test="password != null and password != ''">password = #{password},</if>
<if test="name != null and name != ''">name = #{name},</if>
<if test="gender != null">gender = #{gender},</if>
<if test="phone != null and phone != ''">phone = #{phone},</if>
<if test="job != null">job = #{job},</if>
<if test="salary != null">salary = #{salary},</if>
<if test="image != null and image != ''">image = #{image},</if>
<if test="entryDate != null">entry_date = #{entryDate},</if>
<if test="deptId != null">dept_id = #{deptId},</if>
update_time = #{updateTime}
</set>
WHERE id = #{id}
</update>
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.