fix: prevent negative indentation

This commit is contained in:
Adam Bouqdib 2020-07-06 20:06:30 +01:00 committed by GitHub
parent 3e20dd05c4
commit 168adc3ab7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -291,7 +291,7 @@ export class V2XmlFormatter implements XmlFormatter {
} }
private _getIndent(options: XmlFormattingOptions, indentLevel: number): string { private _getIndent(options: XmlFormattingOptions, indentLevel: number): string {
return ((options.editorOptions.insertSpaces) ? " ".repeat(options.editorOptions.tabSize) : "\t").repeat(indentLevel); return ((options.editorOptions.insertSpaces) ? " ".repeat(options.editorOptions.tabSize) : "\t").repeat(Math.max(indentLevel, 0));
} }
private _removeTrailingNonBreakingWhitespace(text: string): string { private _removeTrailingNonBreakingWhitespace(text: string): string {