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

`trim_trailing_whitespace` not being respected #177

Closed gsklee closed 7 years ago

gsklee commented 7 years ago

Problem

Trailing whitespaces are still being auto-trimmed whenever I hit Cmd-S inside a Markdown file, even though I have the following config:

Involved .editorconfig-files

root = true

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

[*.md]
trim_trailing_whitespace = false

Directory structure

$ tree -a .
zsh: command not found: tree

Installed packages

$ apm list
Built-in Atom Packages (89)
├── atom-dark-syntax@0.28.0
├── atom-dark-ui@0.53.0
├── atom-light-syntax@0.29.0
├── atom-light-ui@0.46.0
├── base16-tomorrow-dark-theme@1.4.0
├── base16-tomorrow-light-theme@1.4.0
├── one-dark-ui@1.8.2
├── one-light-ui@1.8.2
├── one-dark-syntax@1.6.0
├── one-light-syntax@1.6.0
├── solarized-dark-syntax@1.1.1
├── solarized-light-syntax@1.1.1
├── about@1.7.2
├── archive-view@0.62.0
├── autocomplete-atom-api@0.10.0
├── autocomplete-css@0.14.1
├── autocomplete-html@0.7.2
├── autocomplete-plus@2.33.1
├── autocomplete-snippets@1.11.0
├── autoflow@0.29.0
├── autosave@0.23.2
├── background-tips@0.26.1
├── bookmarks@0.43.2
├── bracket-matcher@0.85.1
├── command-palette@0.39.1
├── deprecation-cop@0.55.1
├── dev-live-reload@0.47.0
├── encoding-selector@0.22.0
├── exception-reporting@0.40.0
├── find-and-replace@0.204.5
├── fuzzy-finder@1.4.0
├── git-diff@1.2.0
├── go-to-line@0.31.2
├── grammar-selector@0.48.2
├── image-view@0.60.0
├── incompatible-packages@0.26.1
├── keybinding-resolver@0.35.0
├── line-ending-selector@0.5.1
├── link@0.31.2
├── markdown-preview@0.159.1
├── metrics@1.1.2
├── notifications@0.65.1
├── open-on-github@1.2.1
├── package-generator@1.0.2
├── settings-view@0.244.0
├── snippets@1.0.4
├── spell-check@0.68.5
├── status-bar@1.6.0
├── styleguide@0.48.0
├── symbols-view@0.113.1
├── tabs@0.103.1
├── timecop@0.33.2
├── tree-view@0.211.1
├── update-package-dependencies@0.10.0
├── welcome@0.35.1
├── whitespace@0.35.0
├── wrap-guide@0.39.0
├── language-c@0.54.0
├── language-clojure@0.22.1
├── language-coffee-script@0.48.1
├── language-csharp@0.13.0
├── language-css@0.40.1
├── language-gfm@0.88.0
├── language-git@0.15.0
├── language-go@0.43.0
├── language-html@0.47.1
├── language-hyperlink@0.16.1
├── language-java@0.24.0
├── language-javascript@0.122.0
├── language-json@0.18.3
├── language-less@0.29.6
├── language-make@0.22.2
├── language-mustache@0.13.0
├── language-objective-c@0.15.1
├── language-perl@0.37.0
├── language-php@0.37.3
├── language-property-list@0.8.0
├── language-python@0.45.1
├── language-ruby@0.70.2
├── language-ruby-on-rails@0.25.1
├── language-sass@0.57.0
├── language-shellscript@0.23.0
├── language-source@0.9.0
├── language-sql@0.25.0
├── language-text@0.7.1
├── language-todo@0.29.1
├── language-toml@0.18.1
├── language-xml@0.34.12
└── language-yaml@0.27.1

Community Packages (3) /Users/gsklee/.atom/packages
├── editorconfig@2.2.0
├── oceanic-next@1.0.0
└── sync-settings@0.8.1
florianb commented 7 years ago

Hi @gsklee - thanks for getting in touch!

Unfortunately i am missing your directory-structure and can't reproduce the error.

I can only guess that your markdown-files may lie in subdirectories where the *.md-glob isn't enough to catch them. If you want to catch markdown files in subdirectories, try **/*.md instead. If not, please provide a listing of your directory structure.

dmytrokyrychuk commented 7 years ago

I couldn't reproduce this issue with the following directory structure:

$ tree -a .
.
├── directory
│   └── file2.md
├── .editorconfig
└── file1.md

1 directory, 3 files

Both file1.md and file2.md have the following content (there are 4 spaces behind Line with trailing whitespace) :

# Title

Line with trailing whitespace    

.editorconfig file content is identical to the one @gsklee provided.

When I hit Ctrl+S, spaces at the end of the line Line with trailing whitespace remain unchanged.

Versions:

$ atom --version
Atom    : 1.13.0
Electron: 1.3.13
Chrome  : 52.0.2743.82
Node    : 6.5.0
$ apm list | grep editorconfig
├── editorconfig@2.2.0
gsklee commented 7 years ago

It's the README.md, which is file1.md in @orgkhnargh's example, so @florianb's hypothesis doesn't apply.

http://i.imgur.com/ZQJHu4H.png

Above is my configs for the whitespace package, which might be relevant.

florianb commented 7 years ago

Thanks @orgkhnargh! 🎁

@gsklee the whitespace package is known for interfering the usage of atom-editorconfig. Did you try disabling the whitespace-package?

Also try to get the file status of your README.md (with invoking the EditorConfig: Show State command while the README is opened) and what is the trim_trailing_whitespace-property saying there?

florianb commented 7 years ago

I close this issue due to missing response -- feel free to come back if you think this issue needs more attention.

Thank you for contribution! 💝