sindresorhus / atom-editorconfig

Helps developers maintain consistent coding styles between different editors
https://atom.io/packages/editorconfig
MIT License
812 stars 80 forks source link

EditorConfig does not fix tabs in files. #251

Closed celdorwow closed 1 year ago

celdorwow commented 3 years ago

Hello,

I am currently learning Java. I copy/paste a lot of source files from the internet, which sometimes have inconsistent tab sizes.

I work with Atom and installed EditorConfig to fix files I download. They come with 2, 3 or 4 spaces and as well as hard or soft tabs (spaces). I noticed EditorConfig in Atom does not seem to correct the tabs in any file I try. I have Tab Type in Settings -> Editor set to auto.

For instance, in the following file, each indentation is filled with 2 spaces:

public class HelloWorld {
  public static int x = 7; 
  public int y = 3; 

  public static void main(String[] args) {
    System.out.println("Hello World!");

    HelloWorld a = new HelloWorld();
    HelloWorld b = new HelloWorld();
    a.y = 5;
    b.y = 6;
    a.x = 1;
    b.x = 2;
    System.out.println("a.y = " + a.y);
    System.out.println("b.y = " + b.y);
    System.out.println("a.x = " + a.x);
    System.out.println("b.x = " + b.x);
    System.out.println("HelloWorld.x = " + HelloWorld.x);
  }
}

When I run EditorConfig: Fix File, I get the message:

HelloWorld.java

The file HelloWorld.java conformed to the end_of_line and indent_style properties. No changes were applied.

It seems like EditorConfig considers the file to be correct while it is not, at least according to the .edutorconfig file I shared below. I also run EditorConfig: Show State and got this message:

No problems affecting HelloWorld.java

The editorconfig was applied successfully and the editor for this file should work as expected. If you face any unexpected behavior please report the issue to us Active Configuration EditorConfig settings Current values charset utf8 end_of_line \n indent_size / tab_width 4 indent_style space insert_final_newline true max_line_length unset trim_trailing_whitespace true Note: unset means atom-editorconfig is not influencing a property's behaviour. A full description of all properties can be found on editorconfig.org or their project's Wiki

Is it a bug or have I installed anything that prevents EditorConfig from working?

Thanks

EDIT. My OS is Ubuntu 20.04 LTS.

Involved .editorconfig-files

root = true

[*]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

Directory structure

.
├── .editorconfig
└── tests
    ├── classes
    │   ├── Bicycle.java
    │   ├── Card.java
    │   ├── CreateObjectDemo.java
    │   ├── Deck.java
    │   ├── LocalClassExample.java
    │   ├── Point.java
    │   ├── Rectangle.java
    │   └── TestOfClasses.java
    ├── controlflow
    │   ├── Ifs.java
    │   ├── Loops.java
    │   └── Switch.java
    ├── Fields.java
    ├── HelloWorld.java
    ├── Operators.java
    └── TestOfArrays.java

Installed packages

Built-in Atom Packages (93)
├── atom-dark-syntax@0.29.1
├── atom-dark-ui@0.53.3
├── atom-light-syntax@0.29.1
├── atom-light-ui@0.46.3
├── base16-tomorrow-dark-theme@1.6.0
├── base16-tomorrow-light-theme@1.6.0
├── one-dark-ui@1.12.5
├── one-light-ui@1.12.5
├── one-dark-syntax@1.8.4
├── one-light-syntax@1.8.4
├── solarized-dark-syntax@1.3.0
├── solarized-light-syntax@1.3.0
├── about@1.9.1
├── archive-view@0.65.2
├── autocomplete-atom-api@0.10.7
├── autocomplete-css@0.17.5
├── autocomplete-html@0.8.8
├── autocomplete-plus@2.42.4
├── autocomplete-snippets@1.12.1
├── autoflow@0.29.4
├── autosave@0.24.6
├── background-tips@0.28.0
├── bookmarks@0.46.0
├── bracket-matcher@0.91.2
├── command-palette@0.43.5
├── dalek@0.2.2
├── deprecation-cop@0.56.9
├── dev-live-reload@0.48.1
├── encoding-selector@0.23.9
├── exception-reporting@0.43.1
├── find-and-replace@0.219.7
├── fuzzy-finder@1.14.3
├── github@0.36.9
├── git-diff@1.3.9
├── go-to-line@0.33.0
├── grammar-selector@0.50.1
├── image-view@0.64.0
├── incompatible-packages@0.27.3
├── keybinding-resolver@0.39.0
├── line-ending-selector@0.7.7
├── link@0.31.6
├── markdown-preview@0.160.2
├── metrics@1.8.1
├── notifications@0.71.0
├── open-on-github@1.3.2
├── package-generator@1.3.0
├── settings-view@0.261.7
├── snippets@1.5.1
├── spell-check@0.77.1
├── status-bar@1.8.17
├── styleguide@0.49.12
├── symbols-view@0.118.4
├── tabs@0.110.0
├── timecop@0.36.2
├── tree-view@0.228.2
├── update-package-dependencies@0.13.1
├── welcome@0.36.9
├── whitespace@0.37.7 (disabled)
├── wrap-guide@0.41.0
├── language-c@0.60.19
├── language-clojure@0.22.8
├── language-coffee-script@0.50.0
├── language-csharp@1.1.0
├── language-css@0.44.4
├── language-gfm@0.90.8
├── language-git@0.19.1
├── language-go@0.47.2
├── language-html@0.53.1
├── language-hyperlink@0.17.1
├── language-java@0.32.1
├── language-javascript@0.134.1
├── language-json@1.0.5
├── language-less@0.34.3
├── language-make@0.23.0
├── language-mustache@0.14.5
├── language-objective-c@0.16.0
├── language-perl@0.38.1
├── language-php@0.44.7
├── language-property-list@0.9.1
├── language-python@0.53.5
├── language-ruby@0.72.23
├── language-ruby-on-rails@0.25.3
├── language-rust-bundled@0.1.0
├── language-sass@0.62.1
├── language-shellscript@0.28.2
├── language-source@0.9.0
├── language-sql@0.25.10
├── language-text@0.7.4
├── language-todo@0.29.4
├── language-toml@0.20.0
├── language-typescript@0.6.3
├── language-xml@0.35.3
└── language-yaml@0.32.0

Community Packages (9) /home/xxxx/.atom/packages
├── atom-beautify@0.33.4 (disabled)
├── atom-latex@0.9.1 (disabled)
├── editorconfig@2.6.1
├── language-latex@1.2.0
├── language-lua-wow@0.2.0
├── language-toc-wow@0.2.0
├── latex@0.50.2
├── rainbow-csv@1.4.0
└── wow-spell-tooltips@0.6.1
the-j0k3r commented 2 years ago

possibly related https://github.com/sindresorhus/atom-editorconfig/issues/243

sindresorhus commented 1 year ago

Closing as Atom is abandoned.