Skip to content

Commit

Permalink
added closingBracketNewLine formatting option to package.json
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Chen authored and datho7561 committed Jun 18, 2021
1 parent ba035f9 commit 11e28b9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
20 changes: 19 additions & 1 deletion docs/Formatting.md
Original file line number Diff line number Diff line change
Expand Up @@ -395,4 +395,22 @@ If it is set to `true`, the above document becomes:
<child />
</robot>
```
***
***
### xml.format.closingBracketNewLine

If set to `true`, the closing bracket (`>` or `/>`) of a tag with at least 2 attributes will be put on a new line.

This comment has been minimized.

Copy link
@fbricon

fbricon Jun 18, 2021

Collaborator

why 2 attributes? why not 3? 4? How about using an integer value instead of a boolean?

This comment has been minimized.

Copy link
@datho7561

datho7561 Jun 18, 2021

Contributor

If 1 attribute is present, even with split attributes, everything will be on one line:

<aaa attr1="value" />

If you put the closing bracket on a new line, you get:

<aaa attr1="value"
/>

For more that 1, it makes more sense, since there is one attribute per line, which allows you to reorder them using swap line up/down

<aaa
    attr1="value"
    attr2="value"
...
    attrn="value"
/>

I don't see the use case for only doing this with elements with only for instance > 5 attributes, since it will make the document formatting inconsistent.

I realized when reading over the original issue that we missed indenting the closing bracket as much as the attributes, and modifying the split attributes to split a single attribute across multiple lines. I'll open issues for those components of the original request.


Requires [splitAttributes](#xmlformatsplitattributes) to be set to `true`.

Defaults to `false`.

```xml
<a b="" c="" />
```
becomes
```xml
<a
b=""
c=""
/>
```
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,11 @@
"default": 2,
"markdownDescription": "How many levels to indent the attributes by when `#xml.format.splitAttributes#` is `true`. Default value is `2`. See [here](command:xml.open.docs?%5B%7B%22page%22%3A%22Formatting%22%2C%22section%22%3A%22xmlformatsplitattributesindentsize%22%7D%5D) for more information"
},
"xml.format.closingBracketNewLine": {
"type": "boolean",
"default": false,
"markdownDescription": "The option to put a closing bracket on a newline when `#xml.format.splitAttributes#` is `true`. Default value is `false`. See [here](command:xml.open.docs?%5B%7B%22page%22%3A%22Formatting%22%2C%22section%22%3A%22xmlformatclosingbracketnewline%22%7D%5D) for more information."
},
"xml.preferences.quoteStyle": {
"type": "string",
"enum": [
Expand Down

0 comments on commit 11e28b9

Please sign in to comment.