From 0b892f6f0345658f6a619621b42fcc9f035ba89a Mon Sep 17 00:00:00 2001 From: Josh Johnson Date: Thu, 31 May 2018 19:05:52 -0400 Subject: [PATCH] Indent Closing Tag After Self-Closing Tag Issue: #185 --- src/formatting/formatters/v2-xml-formatter.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/formatting/formatters/v2-xml-formatter.ts b/src/formatting/formatters/v2-xml-formatter.ts index c67b0c9..bed5f8a 100644 --- a/src/formatting/formatters/v2-xml-formatter.ts +++ b/src/formatting/formatters/v2-xml-formatter.ts @@ -169,7 +169,7 @@ export class V2XmlFormatter implements XmlFormatter { indentLevel--; // if the end tag immediately follows a line break, just add an indentation - // if the end tag immediately follows another end tag, add a line break and indent + // if the end tag immediately follows another end tag or a self-closing tag (issue #185), add a line break and indent // otherwise, this should be treated as a same-line end tag(ex. text) if (pc === "\n") { output += `${this._getIndent(options, indentLevel)}<`; @@ -179,6 +179,10 @@ export class V2XmlFormatter implements XmlFormatter { output += `${options.newLine}${this._getIndent(options, indentLevel)}<`; } + else if (pc === ">" && ppc === "/") { + output += `${this._getIndent(options, indentLevel)}<`; + } + else { output += "<"; }