Skip to content
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

Xml Style - continuationIndent for attributes should align to tag name width #4152

Open
nmck257 opened this issue Apr 25, 2024 · 0 comments
Open
Labels
enhancement New feature or request

Comments

@nmck257
Copy link
Collaborator

nmck257 commented Apr 25, 2024

What problem are you trying to solve?

Consider a small pom like this:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>org.sample</groupId>
  <artifactId>sample</artifactId>
  <version>1.0.0</version>
</project>

Observe the indentation (four spaces) of line 3.

If you pass a file like this through XML AutoFormat, you'll get that kind of indentation: continuation indents are 4 spaces by default.
But, if you run IntelliJ's autoformat, then it will indent like this:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>org.sample</groupId>
  <artifactId>sample</artifactId>
  <version>1.0.0</version>
</project>

On line 3, the content has been indented to 9 spaces, aligning with the first attributes of the line above after the tag name.

Describe the solution you'd like

Would be neat if there was an Xml Style / autoformat logic which supports this, and perhaps that should be the default style.

Have you considered any alternatives or workarounds?

Do nothing

Additional context

This indentation heuristic feels a bit unique? Not sure if implementing this would make a mess of the existing Autoformat / Style designs / interfaces.

Are you interested in contributing this feature to OpenRewrite?

I might, but, not a big priority. This might be a decent "first issue"?

@nmck257 nmck257 added the enhancement New feature or request label Apr 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Backlog
Development

No branches or pull requests

1 participant