Add Attribute Splitting

#116
This commit is contained in:
Josh Johnson 2018-01-28 12:09:57 -05:00
parent 8f0bf58462
commit 9941bafa74
5 changed files with 14 additions and 1 deletions

View file

@ -87,6 +87,10 @@ export class V2XmlFormatter implements XmlFormatter {
// entering StartTag.Attribute
else if (location === Location.StartTag && [" ", "/", ">"].indexOf(cc) === -1) {
if (lastNonTextLocation === Location.AttributeValue && ((options.splitXmlnsOnFormat && xml.substr(i, 5).toLowerCase() === "xmlns") || options.splitAttributesOnFormat)) {
output += `${options.newLine}${this._getIndent(options, indentLevel)}`;
}
output += cc;
lastNonTextLocation = location;
location = Location.Attribute;

View file

@ -31,6 +31,7 @@ export class XmlFormattingEditProvider implements DocumentFormattingEditProvider
editorOptions: options,
newLine: (document.eol === EndOfLine.CRLF) ? "\r\n" : "\n",
removeCommentsOnMinify: this.workspaceConfiguration.get<boolean>("removeCommentsOnMinify"),
splitAttributesOnFormat: this.workspaceConfiguration.get<boolean>("splitAttributesOnFormat"),
splitXmlnsOnFormat: this.workspaceConfiguration.get<boolean>("splitXmlnsOnFormat")
});

View file

@ -4,5 +4,6 @@ export interface XmlFormattingOptions {
editorOptions: FormattingOptions;
newLine: string;
removeCommentsOnMinify: boolean;
splitAttributesOnFormat: boolean;
splitXmlnsOnFormat: boolean;
}