Add "addNewLineAfterSelfClosingTag" Option
This commit is contained in:
parent
be6bb72b82
commit
de27295538
4 changed files with 20 additions and 3 deletions
|
@ -78,6 +78,12 @@
|
||||||
"title": "XML Tools Configuration",
|
"title": "XML Tools Configuration",
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
"xmlTools.addNewLineAfterSelfClosingTag": {
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false,
|
||||||
|
"description": "Adds a newline after self-closing XML tags on format.",
|
||||||
|
"scope": "resource"
|
||||||
|
},
|
||||||
"xmlTools.enableXmlTreeView": {
|
"xmlTools.enableXmlTreeView": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"default": true,
|
"default": true,
|
||||||
|
|
|
@ -43,6 +43,10 @@ export class Configuration {
|
||||||
return this._getForWindow<string>("xqueryExecutionInputSearchPattern");
|
return this._getForWindow<string>("xqueryExecutionInputSearchPattern");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static addNewLineAfterSelfClosingTag(resource: Uri): boolean {
|
||||||
|
return this._getForResource<boolean>("addNewLineAfterSelfClosingTag", resource);
|
||||||
|
}
|
||||||
|
|
||||||
static enforcePrettySelfClosingTagOnFormat(resource: Uri): boolean {
|
static enforcePrettySelfClosingTagOnFormat(resource: Uri): boolean {
|
||||||
return this._getForResource<boolean>("enforcePrettySelfClosingTagOnFormat", resource);
|
return this._getForResource<boolean>("enforcePrettySelfClosingTagOnFormat", resource);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import { EndOfLine, FormattingOptions, TextDocument } from "vscode";
|
import { EndOfLine, FormattingOptions, TextDocument } from "vscode";
|
||||||
|
|
||||||
import { Configuration } from "../common";
|
import { Configuration } from "../common";
|
||||||
import * as constants from "../constants";
|
|
||||||
|
|
||||||
export interface XmlFormattingOptions {
|
export interface XmlFormattingOptions {
|
||||||
editorOptions: FormattingOptions;
|
editorOptions: FormattingOptions;
|
||||||
|
@ -11,6 +10,7 @@ export interface XmlFormattingOptions {
|
||||||
splitAttributesOnFormat: boolean;
|
splitAttributesOnFormat: boolean;
|
||||||
splitXmlnsOnFormat: boolean;
|
splitXmlnsOnFormat: boolean;
|
||||||
initialIndentLevel?: number;
|
initialIndentLevel?: number;
|
||||||
|
addNewLineAfterSelfClosingTag: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class XmlFormattingOptionsFactory {
|
export class XmlFormattingOptionsFactory {
|
||||||
|
@ -22,7 +22,8 @@ export class XmlFormattingOptionsFactory {
|
||||||
removeCommentsOnMinify: Configuration.removeCommentsOnMinify(document.uri),
|
removeCommentsOnMinify: Configuration.removeCommentsOnMinify(document.uri),
|
||||||
splitAttributesOnFormat: Configuration.splitAttributesOnFormat(document.uri),
|
splitAttributesOnFormat: Configuration.splitAttributesOnFormat(document.uri),
|
||||||
splitXmlnsOnFormat: Configuration.splitXmlnsOnFormat(document.uri),
|
splitXmlnsOnFormat: Configuration.splitXmlnsOnFormat(document.uri),
|
||||||
initialIndentLevel: 0
|
initialIndentLevel: 0,
|
||||||
|
addNewLineAfterSelfClosingTag: Configuration.addNewLineAfterSelfClosingTag(document.uri)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,9 @@ describe("V2XmlFormatter", () => {
|
||||||
newLine: "\r\n",
|
newLine: "\r\n",
|
||||||
removeCommentsOnMinify: false,
|
removeCommentsOnMinify: false,
|
||||||
splitAttributesOnFormat: false,
|
splitAttributesOnFormat: false,
|
||||||
splitXmlnsOnFormat: true
|
splitXmlnsOnFormat: true,
|
||||||
|
addNewLineAfterSelfClosingTag: false
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
it("should handle basic XML", () => {
|
it("should handle basic XML", () => {
|
||||||
|
@ -97,7 +99,11 @@ describe("V2XmlFormatter", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should optionally add line break after self-closing tag", () => {
|
it("should optionally add line break after self-closing tag", () => {
|
||||||
|
options.addNewLineAfterSelfClosingTag = true;
|
||||||
|
|
||||||
testFormatter(xmlFormatter, options, "issue-235");
|
testFormatter(xmlFormatter, options, "issue-235");
|
||||||
|
|
||||||
|
options.addNewLineAfterSelfClosingTag = false;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue