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

VSCode will insert an empty line to .editorconfig in spite of insert_final_newline = false #209

Open
1 of 3 tasks
tats-u opened this issue Dec 21, 2018 · 9 comments
Open
1 of 3 tasks

Comments

@tats-u
Copy link

tats-u commented Dec 21, 2018

Please fill-in this template.

  • I have a question that is specific to this extension; thus, inappropriate for the main EditorConfig issue tracker.
  • I tried running code --disable-extensions and the issue did NOT present itself.

Delete the following condition if it doesn't apply to your case:

If the extension is not picking up the expected configuration for a file:

  • I tried npm install editorconfig -g and ran editorconfig [file-in-question] and the configuration was what I expected. If not, please file on the editorconfig-core-js issue tracker.

Issue

Visual Studio Code editorconfig-vscode
Version 1.30.1 0.12.5

Root .editorconfig File

root = true

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

[*.py]
indent_size = 4

[*.md]
trim_trailing_whitespace = false

[{Makefile,Makefile*,*.mk}]
indent_style = tab
indent_size = 4
tab_width = 4

Are there any other relevant .editorconfig files in your project? Yes / No

Visual Studio Code Setting Default User Workspace
editor.insertSpaces true true ____
editor.tabSize 4 4 _
editor.trimAutoWhitespace true true ____
files.autoSave "off" "off" "___"
files.insertFinalNewline false true _____
files.trimTrailingWhitespace false true _____

File opened

./.editorconfig

Expected behavior

insert_final_newline = false

Actual behavior

insert_final_newline = true

Additional comments or steps to reproduce

  1. Create an .editorconfig in the root
  2. Save
  3. Remove the appended empty line
  4. Save again

Related: #153

@jednano
Copy link
Member

jednano commented Dec 21, 2018

This issue is pretty much the same thing as #153

@tats-u
Copy link
Author

tats-u commented Dec 24, 2018

I know it. I posted this issue because I'd like to say insert_final_newline also has a problem not only trim_trailling_whitespace. This can be closed at the same time as #153.

@jednano
Copy link
Member

jednano commented Dec 24, 2018

The only strategy I can think of is to save the file contents, let vscode do it's trimming and then manually untrim it after the fact, but I refuse to do anything that hacky.

@tats-u
Copy link
Author

tats-u commented Dec 24, 2018

I read the implementation of InsertFinalNewLine (https://github.com/editorconfig/editorconfig-vscode/blob/0199ff82a8573b781e2f2adb04b5eb1288372c07/src/transformations/InsertFinalNewline.ts). This extension does these operations BY ITSELF, not leaving them to VSCode.
I would try to control the behavior of Code (whether it remove trailling whitespace and so on) if I were a developer of this extension.

@jednano
Copy link
Member

jednano commented Dec 24, 2018

Good point. That feature didn't exist at the time of implementation.

@tats-u
Copy link
Author

tats-u commented Dec 24, 2018

I got it. Code does support all of them now but I wonder if it allows us to enforce / suppress them by extensions.

@jednano
Copy link
Member

jednano commented Dec 24, 2018

You're right that we just need to let Code do what Code does and not get in its way. I'll look into this more when I have some time and of course PRs welcome.

@tats-u
Copy link
Author

tats-u commented Dec 24, 2018

Thank you for your understanding.

@jednano
Copy link
Member

jednano commented Dec 25, 2018

@tats-u the more and more I look into this issue, the more I'm convinced it should be fixed first at the vscode level. I opened an issue about it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants