-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Preserve attribute line breaks #772
Conversation
This PR is ready for review. Instead of introducing a formatting setting that keeps all newlines from non-empty lines, this PR introduces a new formatting setting, (ie, in VS Code: For example:
The formatter will keep These characteristics are useful in these cases: End tag closing bracket is in a new line
formats to
Attribute name/delimiter/value on separate lines
formats to
As a plus, this setting will not will not keep newlines inside of the XML declaration ( To review this PR with VS Code, please also check out redhat-developer/vscode-xml#271, which adds the Demo:
|
The gif is a bit misleading since the attribute names are all aligned since the tab size is 4 spaces. This PR will indent the attribute names depending on the element's indentation and will not align attribute names for the moment. I created a new issue for attribute aligning here: #272 |
org.eclipse.lemminx/src/main/java/org/eclipse/lemminx/services/XMLFormatter.java
Outdated
Show resolved
Hide resolved
|
||
private void formatAttributes(DOMElement element) throws BadLocationException { | ||
List<DOMAttr> attributes = element.getAttributeNodes(); | ||
if (hasSingleAttributeInFullDoc(element)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The process looks pretty similar for one attribute and many attributes. Is it possible to avoid checking if there is one attribute, and use a general process that works for any number?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
org.eclipse.lemminx/src/main/java/org/eclipse/lemminx/services/XMLFormatter.java
Outdated
Show resolved
Hide resolved
org.eclipse.lemminx/src/main/java/org/eclipse/lemminx/services/XMLFormatter.java
Outdated
Show resolved
Hide resolved
Signed-off-by: David Kwon <[email protected]>
Signed-off-by: David Kwon [email protected]