vscode-xml: XML Formatter Fails: `RangeError: Invalid count value`

Description

When I was formatting an xml using ALT + SHIFT + F, it stops responding. Nothing, no errors being thrown out as a pop-up.

Screenshots VS Code Output - Extension Host

2019-01-21 14:17:19.085] [exthost] [error] RangeError: Invalid count value
	at String.repeat (native)
	at V2XmlFormatter._getIndent (C:\Users\thomashan\.vscode\extensions\dotjoshjohnson.xml-2.4.0\out\formatting\formatters\v2-xml-formatter.js:206:106)
	at V2XmlFormatter.formatXml (C:\Users\thomashan\.vscode\extensions\dotjoshjohnson.xml-2.4.0\out\formatting\formatters\v2-xml-formatter.js:167:39)
	at XmlFormattingEditProvider.provideDocumentRangeFormattingEdits (C:\Users\thomashan\.vscode\extensions\dotjoshjohnson.xml-2.4.0\out\formatting\xml-formatting-edit-provider.js:39:41)
	at XmlFormattingEditProvider.provideDocumentFormattingEdits (C:\Users\thomashan\.vscode\extensions\dotjoshjohnson.xml-2.4.0\out\formatting\xml-formatting-edit-provider.js:12:21)
	at c:\Users\thomashan\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:557:303
	at t.asThenable (c:\Users\thomashan\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:141:941)
	at new module.exports.t.exports (C:\Users\thomashan\.vscode\extensions\vscjava.vscode-maven-0.13.0\dist\extension.js:126:25764)
	at Object.t.asThenable (c:\Users\thomashan\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:141:909)
	at e.provideDocumentFormattingEdits (c:\Users\thomashan\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:557:262)
	at c:\Users\thomashan\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:572:705
	at e._withAdapter (c:\Users\thomashan\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:567:513)
	at e.$provideDocumentFormattingEdits (c:\Users\thomashan\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:572:667)
	at t._doInvokeHandler (c:\Users\thomashan\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:658:837)
	at t._invokeHandler (c:\Users\thomashan\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:658:509)
	at t._receiveRequest (c:\Users\thomashan\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:657:60)
	at t._receiveOneMessage (c:\Users\thomashan\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:656:59)
	at c:\Users\thomashan\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:653:895
	at c:\Users\thomashan\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:130:793
	at e.fire (c:\Users\thomashan\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:133:218)
	at a (c:\Users\thomashan\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:186:147)
	at Socket.n._socketDataListener (c:\Users\thomashan\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:186:368)
	at emitOne (events.js:116:13)
	at Socket.emit (events.js:211:7)
	at addChunk (_stream_readable.js:263:12)
	at readableAddChunk (_stream_readable.js:250:11)
	at Socket.Readable.push (_stream_readable.js:208:10)
	at Pipe.onread (net.js:594:20)

Extension Version v2.4.0 I believe

VS Code Version 1.30.2

Operating System Windows 10

Additional Information

file name: Spring.Data.xml file length: 10922 lines

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 18 (2 by maintainers)

Commits related to this issue

Most upvoted comments

Just had this too. Nothing helps

I had the same issue. Here’s an example that triggers this:

<?xml version="1.0" encoding="UTF-8"?>
<test1>
    TEST <test2>aaa</test2>
</test1>

or a more realistic example:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="xml" encoding="UTF-8" indent="yes" />

    <xsl:template match="/">
        <file>
            <xsl:apply-templates />
        </file>
    </xsl:template>

    <xsl:template match="*">
        <xsl:message terminate="no">
            WARNING: Unmatched element: <xsl:value-of select="name()"/>
        </xsl:message>
        <xsl:apply-templates/>
    </xsl:template>

</xsl:stylesheet>

Same problem here. Please re-open.

Has there been any investigation in to this issue? Since this one was automatically closed by a bot should a new issue be opened instead? There is a very simple example of how to reproduce this issue in comment https://github.com/DotJoshJohnson/vscode-xml/issues/257#issuecomment-462768486.