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

Wrong behaviour with `insert_final_newline = true` and `"files.autoSave": "afterDelay"`

Open psnet opened this issue 4 years ago • 5 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

Visual Studio Code editorconfig-vscode
Version 1.63.2 v0.16.4

Root .editorconfig File

# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

# Matches multiple files with brace expansion notation
[*.{js,ts,tsx}]
charset = utf-8
indent_style = space
indent_size = 4

# Tab indentation (no size specified)
[Makefile]
indent_style = tab

# Matches the exact files either package.json or .travis.yml
[{package.json,.travis.yml}]
indent_style = space
indent_size = 2

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" "afterDelay" "___"
files.insertFinalNewline false _____ _____
files.trimTrailingWhitespace false _____ _____

File opened

./file.ts

Expected behavior

When typing on last line in file and when (on auto save) added new insert_final_newline = true text cursor will stay where I stop typing.

Actual behavior

When typing something on last line of file and stop typing after auto save (after delay) will be added new empty line (due config insert_final_newline = true) and text cursor will be moved on that new empty line so need manually back to previous line to continue typing.

psnet avatar Jan 09 '22 16:01 psnet

I also have this issue - It is quite annoying

cgaube avatar Feb 23 '22 04:02 cgaube

+1

In fact this behaviour is not consistent with trim_trailing_whitespace=true + afterDelay. In that case the trailing whitespaces are removed only when forcing to save the file

tercebusuu avatar May 10 '22 12:05 tercebusuu

I also have this issue. I found out vscode used to have it also and they fixed, hopefully won't be hard for editorconfig-vscode to replicate the fix.

LeonnardoVerol avatar Feb 07 '24 17:02 LeonnardoVerol

This is a major annoying issue for years. Also reported on StackOverflow (turn feature off, problem solved! LOL).

Does the related fix in VSCode inspire someone to work on this issue?

bittner avatar May 14 '24 19:05 bittner

File > Preferences > Settings > Auto Save

changing the 'auto save' setting to 'onFocusChange' You can work normally now

image

ajiho avatar Aug 21 '24 10:08 ajiho