eclipse-theia / theia

Eclipse Theia is a cloud & desktop IDE framework implemented in TypeScript.
http://theia-ide.org
Eclipse Public License 2.0
19.94k stars 2.49k forks source link

feat: add support for files.insertFinalNewline during formatOnSave #13751

Open xai opened 4 months ago

xai commented 4 months ago

What it does

When the files.insertFinalNewline property is set to true, formatOnSave() will ensure that the file ends with a newline character instead of always removing a final empty line.

Fixes #13475

Contributed on behalf of STMicroelectronics

How to test

  1. Open a workspace and set "editor.formatOnSave" to true in the workspace settings.
  2. Edit a file that has a final empty line and save.
  3. Verify that the empty line has been removed.
  4. Set "files.insertFinalNewline" to true in the workspace settings.
  5. Verify that final empty lines are kept or added when saving.

Follow-ups

Review checklist

Reminder for reviewers

JonasHelming commented 3 months ago

@xai What is the state of this?

xai commented 3 months ago

@xai What is the state of this?

As I commented in the related issue, I feel that the added protected function might be living in the wrong place. But it works, and I do not know what would be a better file/package for that function, so I am just going to remove the draft state now and hope for input from a reviewer.

xai commented 3 months ago

@tsmaeder alerted me that the property seems to be ignored in certain cases:

Merging as is does not make sense, because it will not work in most cases (i.e., all built-in extensions are present). So, I am going to debug into this to find out which extension we are having this feature interaction with.