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

If U+FEFF (BOM) is present, running formatter deletes all code in a file #1013

Closed
FylmTM opened this issue Dec 16, 2020 · 1 comment · Fixed by #1027
Closed

If U+FEFF (BOM) is present, running formatter deletes all code in a file #1013

FylmTM opened this issue Dec 16, 2020 · 1 comment · Fixed by #1027
Labels

Comments

@FylmTM
Copy link

FylmTM commented Dec 16, 2020

Expected Behavior

Code should be put back into a file, but formatted.

Observed Behavior

All code in a file that has violation is deleted.

Steps to Reproduce

Create test.kt file with content:

val b = "text" +
                "another text"

Run formatter:

ktlint -F test.kt

Before:

$ cat test.kt
<U+FEFF>val b = "text" +
    "another text"

After:

$ cat test.kt
<U+FEFF>

Your Environment

  • Version of ktlint used: 0.40.0
  • Name and version (or code for custom task) of integration used (Gradle plugin, Maven plugin, command line, custom Gradle task): ktlint (installed via brew), kotlinter-gradle plugin)
  • Version of Gradle used (if applicable): 6.5.1
  • Operating System and version: macOS Big Sur
@FylmTM FylmTM changed the title Running formatter deletes all code in a file for "Unexpected indentation" rule Running formatter deletes all code in a file if "Unexpected indentation" rule is violated Dec 16, 2020
@FylmTM
Copy link
Author

FylmTM commented Dec 16, 2020

I have encountered this bug when configuring ktlint for our project. We had some files that had (for unknown reasons) BOM set.

As a fix for myself - I am going to remove BOM from those files.

@FylmTM FylmTM changed the title Running formatter deletes all code in a file if "Unexpected indentation" rule is violated If U+FEFF (BOM) is present, running formatter deletes all code in a file Dec 16, 2020
@Tapchicoma Tapchicoma added the bug label Dec 16, 2020
paul-dingemans pushed a commit to paul-dingemans/ktlint that referenced this issue Dec 20, 2020
romtsn pushed a commit that referenced this issue Dec 20, 2020
#1027)

Solves #1013

Co-authored-by: Paul Dingemans <pdingemans@bol.com>
romtsn pushed a commit to paul-dingemans/ktlint that referenced this issue Mar 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants