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

insert_final_newline clashes with trim_trailing_whitespace #221

Closed mcandre closed 1 year ago

mcandre commented 6 years ago

Summary

I need to have the .patch file I am editing end with a line consisting of a single ASCII space character, followed by a final ASCII line feed character. However, Atom's EditorConfig plugin has insert_final_newline misbehaving when trim_trailing_whitespace is disabled: When I try to save the file, the EditorConfig plugin deletes the trailing space character, corrupting the patch file.

Sample file

--- /bin/termrc Mon Nov 29 12:33:01 2010
+++ /bin/termrc.new Sun May 27 11:23:58 2018
@@ -42,8 +42,8 @@
 #
 # If your site provides DHCP service,
 #
-#if(! test -e /net/ipifc/0/ctl)
-#  ip/ipconfig
+if(!test -e /net/ipifc/0/ctl)
+   ip/ipconfig
 # Otherwise, see /cfg/$sysname/termrc (/cfg/example/termrc is an example).

Involved .editorconfig-files

root = true

# Most text files
[*]
charset = utf-8
insert_final_newline = true
trim_trailing_whitespace = true
max_line_length = none
indent_style = space

# patchfiles
[*.patch]
trim_trailing_whitespace = false

Installed packages

$ apm list
Built-in Atom Packages (92)
├── atom-dark-syntax@0.29.0
├── atom-dark-ui@0.53.2
├── atom-light-syntax@0.29.0
├── atom-light-ui@0.46.2
├── base16-tomorrow-dark-theme@1.5.0
├── base16-tomorrow-light-theme@1.5.0
├── one-dark-ui@1.12.1
├── one-light-ui@1.12.1
├── one-dark-syntax@1.8.2
├── one-light-syntax@1.8.2
├── solarized-dark-syntax@1.1.4
├── solarized-light-syntax@1.1.4
├── about@1.8.1
├── archive-view@0.64.3
├── autocomplete-atom-api@0.10.7
├── autocomplete-css@0.17.5
├── autocomplete-html@0.8.4
├── autocomplete-plus@2.40.6 (disabled)
├── autocomplete-snippets@1.12.0
├── autoflow@0.29.3
├── autosave@0.24.6
├── background-tips@0.28.0
├── bookmarks@0.45.1
├── bracket-matcher@0.89.2
├── command-palette@0.43.5
├── dalek@0.2.2
├── deprecation-cop@0.56.9 (disabled)
├── dev-live-reload@0.48.1
├── encoding-selector@0.23.8
├── exception-reporting@0.43.1
├── find-and-replace@0.215.9
├── fuzzy-finder@1.8.1
├── github@0.14.3
├── git-diff@1.3.9
├── go-to-line@0.33.0
├── grammar-selector@0.50.1
├── image-view@0.62.4
├── incompatible-packages@0.27.3
├── keybinding-resolver@0.38.1
├── line-ending-selector@0.7.6
├── link@0.31.4
├── markdown-preview@0.159.20
├── metrics@1.2.6
├── notifications@0.70.5
├── open-on-github@1.3.1
├── package-generator@1.3.0
├── settings-view@0.254.2
├── snippets@1.3.3
├── spell-check@0.73.4
├── status-bar@1.8.15
├── styleguide@0.49.11
├── symbols-view@0.118.2
├── tabs@0.109.1
├── timecop@0.36.2
├── tree-view@0.222.0
├── update-package-dependencies@0.13.1
├── welcome@0.36.6
├── whitespace@0.37.5 (disabled)
├── wrap-guide@0.40.3
├── language-c@0.59.3
├── language-clojure@0.22.7
├── language-coffee-script@0.49.3
├── language-csharp@1.0.1
├── language-css@0.42.10
├── language-gfm@0.90.3
├── language-git@0.19.1
├── language-go@0.45.3
├── language-html@0.49.0
├── language-hyperlink@0.16.3
├── language-java@0.29.0
├── language-javascript@0.128.5
├── language-json@0.19.1
├── language-less@0.34.2
├── language-make@0.22.3
├── language-mustache@0.14.5
├── language-objective-c@0.15.1
├── language-perl@0.38.1
├── language-php@0.43.2
├── language-property-list@0.9.1
├── language-python@0.49.5
├── language-ruby@0.71.4
├── language-ruby-on-rails@0.25.3
├── language-sass@0.61.4
├── language-shellscript@0.26.3
├── language-source@0.9.0
├── language-sql@0.25.10
├── language-text@0.7.4
├── language-todo@0.29.4
├── language-toml@0.18.2
├── language-typescript@0.3.3
├── language-xml@0.35.2
└── language-yaml@0.32.0

Community Packages (59) /Users/andrew/.atom/packages
├── Stylus@3.1.1
├── busy-signal@1.4.3
├── cucumber@0.6.0
├── dalek@0.2.1
├── deprecation-cop@0.56.9 (disabled)
├── editorconfig@2.2.2
├── github@0.9.1
├── intentions@1.1.5
├── language-arm@1.2.2
├── language-awk@0.1.12
├── language-batch@0.4.0
├── language-brainfuck@0.2.0
├── language-cmake@1.1.0
├── language-coq@0.1.0
├── language-d@3.3.1
├── language-docker@1.1.8
├── language-erlang@3.2.0
├── language-fish-shell@1.1.0
├── language-forth@0.2.3
├── language-fortran@2.1.6
├── language-fsharp@0.8.4
├── language-generic-config@1.4.0
├── language-gitignore@0.3.0
├── language-groovy@0.7.0
├── language-haskell@1.17.3
├── language-ini@1.19.0
├── language-latex@1.1.1
├── language-lisp@0.2.0
├── language-llvm@0.1.1
├── language-lua@0.9.11
├── language-matlab@0.2.1
├── language-newlisp@0.1.0
├── language-ocaml@1.9.5
├── language-oz@0.1.0
├── language-pascal@0.20.6
├── language-patch@1.2.0
├── language-pgsql@0.2.3
├── language-powershell@4.0.0
├── language-r@0.4.2
├── language-rust@0.4.12
├── language-scala@1.1.9
├── language-scheme@1.4.0
├── language-smalltalk@1.0.2
├── language-sml@0.7.0
├── language-swift@0.5.0
├── language-tcl@0.1.2
├── language-vala@0.2.0
├── language-viml@1.1.6
├── language-x86@1.0.1
├── line-ending-selector@0.7.5
├── linter@2.2.0
├── linter-flake8@2.3.0 (disabled)
├── linter-ui-default@1.6.10
├── minimap@4.29.7
├── monokai@0.24.0
├── monokai-shade@0.4.0
├── release-notes@0.53.0
├── shebang-set-grammar@0.8.0
└── sync-settings@0.8.3

I'm using macOS High Sierra in case that matters.

florianb commented 6 years ago

Hi @mcandre - the insert_final_newline-option's intend is to let the file end with a final newline character. I'd suggest you should also disable insert_final_newline for patch-files.

Clijsters commented 6 years ago

I don't really get why mcandre should disable an option which is - as described - necessary oO

sindresorhus commented 1 year ago

Closing as Atom is abandoned.