Studio does not respect native line endings when creating new files

I usually work on macos and linux, but unfortunately there are less lucky gals who need to work on Windows boxes too.

For those on Windows, I just noticed that Studio creates files with the LF line ending, despite being on Windows. I would expect it to create most of the files with the CRLF line ending (with some exceptions, like .sh files and such).

That’s not ideal, but it could be fine if it consistently uses LF for all the files it creates, but unfortunately it’s not the case.
For example, after inspecting some files created in a new test project, I noticed that the file modules\core\src\com\company\app\core\ has been created with the CRLF line ending, while the other files in the core module have the LF line ending.
This is really bad for Git, because inconsistent line endings means trouble when sharing projects between macos/linux and Windows.

I think that Studio should respect the native line endings of the underlying S.O., like Git does with the core.eol = native config. In addition, it should create a default .gitattributes file for a new project, with sane default values for the main files in it (see a sample at the end of the post).
If that’s not possible, at least try to be consistent, and never mix LF and CRLF line endings like it does in the current version.


APPENDIX: sample .gitattributes file (expand at will)

# Set behaviour for all files, and override core.autocrlf
* text=auto

# Explicitly declare text files we want to always be normalized and converted to native line endings on checkout.
*.txt text diff
*.exp text diff
*.yml text diff
*.js  text diff
*.md  text diff
*.MD  text diff
*.gitignore text diff
*.gitattributes text diff

# Declare common diff patterns for specific file types
*.htm    text diff=html
*.html   text diff=html
*.java   text diff=java

# Declare files that will always have CRLF line endings on checkout.
*.ps1           text diff eol=crlf
*.bat           text diff eol=crlf
*.cmd           text diff eol=crlf

# Declare files that will always have LF line endings on checkout
*.sh              text diff eol=lf
*.command         text diff eol=lf
package.json      text diff eol=lf

# Prevent EOL conversions (but treat as text)
tsd.json -text
repositories.config  -text
packages.config      -text
.idea/**/*.xml       -text

# Denote all files that should be treated as binary and should not be modified.
*.zip           binary
*.ai            binary
*.svg           binary
*.pdf           binary
*.jpg           binary
*.png           binary
*.bmp           binary
*.psd           binary
*.iml           binary
*.plist         binary

Hi, Paolo
Thanks for your feedback.

The issue with mixed line endings was fixed in

For now we don’t have plans to change the approach to files creation. All files created by Studio should have LF line endings.

Hi @gaslov,
what about the upcoming Studio IDEA plugin for v.7 ? I should expect the same behavior there?

I want to add that this can cause issues with Git, because if Studio creates files with LF endings, and IDEA (on Windows) creates files with native EOLs (CRLF) we’ll end up with mixed line endings in the repo.
This is something that you should address, IMHO.


Thanks again for raising the issue.
We do have mixed line ending in projects created by Studio 7.BETA.
In Studio 7 release we consider using IDEA line separator setting. It is ‘System-Dependent’ by default.