editorconfig-vscode icon indicating copy to clipboard operation
editorconfig-vscode copied to clipboard

`insert_final_newline = false` not working

Open ccmywish opened this issue 2 years ago • 6 comments

Please fill-in this template.

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

Issue

On Windows 11

Visual Studio Code editorconfig-vscode
Version 1.76.1 0.16.4

Root .editorconfig File

root = true

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

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

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

File opened

Any file

Expected behavior

Without adding final new line automatically when insert_final_newline = false

Actual behavior

Always adding final new line automatically

ccmywish avatar Mar 15 '23 00:03 ccmywish

Same here, very annoying.

RobertAKARobin avatar Mar 16 '23 17:03 RobertAKARobin

As a workaround, the user can enable the global VSCode Trim Final Newlines option.

However, that has poor integration with EditorConfig. And, if you happen to be working on text fixtures, then you cannot adjust this setting on a per directory basis. You're stuck with either over-sanitized test fixture files, or else under-sanitized source code files.

mcandre avatar Apr 24 '23 22:04 mcandre

@mcandre While you can't adjust the setting on per-directory basis, you can on per-language instead. So something like this in the settings.json:

{
  "[javascript]": {
    "files.insertFinalNewline": true,
    "files.trimFinalNewlines": true
  },
  "[markdown]": {
    "files.insertFinalNewline": false
    "files.trimFinalNewlines": false
  },
}

Per-directory can be achieved too but only for vscode, by creating ./vscode/settings.json in the directory with the settings you need.

GabenGar avatar May 04 '23 09:05 GabenGar

I have it too: insert_final_newline = false is not respected, if the user setting of VS Code has this set to true.

Please fix this or at least mention in the readme too.

serkonda7 avatar May 05 '23 15:05 serkonda7

I am not a fan of configuring text editors. I float between several. I specifically use EditorConfig to avoid this problem. If I wanted to perform the configuration with VSCode, then I wouldn't be using EditorConfig.

mcandre avatar May 08 '23 22:05 mcandre

Same problem. Please fix it 😭😭

hardingadonis avatar Aug 08 '24 16:08 hardingadonis