diff --git a/src/formatting/formatters/v2-xml-formatter.ts b/src/formatting/formatters/v2-xml-formatter.ts index 19b1dd1..3f85734 100644 --- a/src/formatting/formatters/v2-xml-formatter.ts +++ b/src/formatting/formatters/v2-xml-formatter.ts @@ -121,21 +121,6 @@ export class V2XmlFormatter implements XmlFormatter { output += `>${options.newLine}`; } - // if this is an open tag followed by a line break, add an indent before the text (after the line break) - // TODO: there could be multiple lines of text here, so we'll need a less naive implementation at some point - else if (nc === "\r" || nc === "\n") { - output += `>${options.newLine}${this._getIndent(options, indentLevel)}`; - - // fast-forward based on what type of line break was used - if (nc === "\r") { - i += 2; - } - - else { - i++; - } - } - else { output += ">"; } diff --git a/src/test/extension.test.ts b/src/test/extension.test.ts index e5de0ab..7f51b01 100644 --- a/src/test/extension.test.ts +++ b/src/test/extension.test.ts @@ -28,6 +28,18 @@ describe("V2XmlFormatter", () => { testFormatter(xmlFormatter, options, "basic"); }); + it("should handle unicode element names", () => { + testFormatter(xmlFormatter, options, "unicode"); + }); + + it("should handle self-closing elements", () => { + testFormatter(xmlFormatter, options, "self-closing"); + }); + + it("should handle text-only lines", () => { + testFormatter(xmlFormatter, options, "text-only-line"); + }); + }); }); diff --git a/src/test/test-data/self-closing.formatted.xml b/src/test/test-data/self-closing.formatted.xml new file mode 100644 index 0000000..e37f362 --- /dev/null +++ b/src/test/test-data/self-closing.formatted.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/test/test-data/self-closing.unformatted.xml b/src/test/test-data/self-closing.unformatted.xml new file mode 100644 index 0000000..c24f1dd --- /dev/null +++ b/src/test/test-data/self-closing.unformatted.xml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/test/test-data/text-only-line.formatted.xml b/src/test/test-data/text-only-line.formatted.xml new file mode 100644 index 0000000..8c8717d --- /dev/null +++ b/src/test/test-data/text-only-line.formatted.xml @@ -0,0 +1,6 @@ + + +Text1 +Text2 + + \ No newline at end of file diff --git a/src/test/test-data/text-only-line.unformatted.xml b/src/test/test-data/text-only-line.unformatted.xml new file mode 100644 index 0000000..43436ac --- /dev/null +++ b/src/test/test-data/text-only-line.unformatted.xml @@ -0,0 +1,6 @@ + + +Text1 +Text2 + + \ No newline at end of file diff --git a/src/test/test-data/unicode.formatted.xml b/src/test/test-data/unicode.formatted.xml new file mode 100644 index 0000000..a19a993 --- /dev/null +++ b/src/test/test-data/unicode.formatted.xml @@ -0,0 +1,4 @@ + +<Имя> + text + \ No newline at end of file diff --git a/src/test/test-data/unicode.unformatted.xml b/src/test/test-data/unicode.unformatted.xml new file mode 100644 index 0000000..098f43f --- /dev/null +++ b/src/test/test-data/unicode.unformatted.xml @@ -0,0 +1,2 @@ + +<Имя>text \ No newline at end of file