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

ImportOrderingRule breaks when ij_kotlin_imports_layout entry has spaces after commas #1223

Closed
Kernald opened this issue Aug 30, 2021 · 2 comments

Comments

@Kernald
Copy link

Kernald commented Aug 30, 2021

Expected Behavior

Spaces in .editorconfig's ij_kotlin_imports_layout should not matter. E.g. this:

ij_kotlin_imports_layout = *,^

Should behave in the exact same way as this:

ij_kotlin_imports_layout = *, ^

Observed Behavior

ktlint seems to stop parsing the line at the first whitespace. With ij_kotlin_imports_layout = *, ^, I get the same results as ij_kotlin_imports_layout = *. Note that IntelliJ properly supports whitespaces.

Steps to Reproduce

  1. Set this in your .editorconfig, and reformat it:
[.editorconfig]
ij_editorconfig_space_after_comma = true

[{*.kt, *.kts}]
ij_kotlin_imports_layout = *,^
  1. Run ktlint -F on a file with an import alias. Notice the ordering is now incorrect.

Your Environment

  • Version of ktlint used: Tested in both 0.41.0 and 0.42.1
  • Name and version (or code for custom task) of integration used (Gradle plugin, Maven plugin, command line, custom Gradle task): CLI
  • Version of Gradle used (if applicable): n/a
  • Operating System and version: macOS 11.5.2
  • Link to your project (if it's a public repository): n/a
@paul-dingemans
Copy link
Collaborator

In the readme a similar problem is documented: https://github.com/pinterest/ktlint#intellij-idea-editorconfig-autoformat-issue which was documented as a result of #762. Both that problem as well as this issue can be prevented by advising to disable this setting and reformat all '.editorconfig' files in the project.

[.editorconfig]
ij_editorconfig_space_after_comma = false # Workaround for parsing problem of .editorconfig by KtLint

@Kernald
Copy link
Author

Kernald commented Sep 7, 2021

Woops, sorry I didn't see the readme entry nor the existing issue. Sorry for the noise.

@Kernald Kernald closed this as completed Sep 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants