Skip to content

Can we allow users to control final newline and trim whitespace independent of save without formatting #176594

@mgsh

Description

@mgsh

#38695 had introduced the option of save without formatting which is very useful in working on projects which don't already have a formatter enabled and keeps diffs small and relevant to the lines being changed.

Problem:
But I had assumed that "files.insertFinalNewline": true, was an independent feature which can be turned on or off. But I realized when I found the above issue that save without formatting was designed to silently disable other flags as well. This leads to a situation where I have to remember to add a newline manually when saving without formatting. Recently I found a workaround in the form of an extension which does exactly what I want, so I have a working solution (at least until that extension breaks for some future version), but I believe giving user control over what gets disabled as part of save without formatting would help, or at least visibility into what it disables (so that there are no surprises, because for sometime I suspected it was because of the vscode-neovim plugin).

Other considerations:

  1. I didn't want to disable formatting altogether for the project because for new files in the same project I would like to save (with formatting).
  2. Or maybe format file can become a separate option that users can explicitly call (similar to trim trailing whitespaces). That will also allow me flexibility to opt-in to formatting (as a special feature) rather than it being done implicitly together with newline and trailing whitespace.

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature-requestRequest for new features or functionalityformattingSource formatter issues

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions