Temporarily Set Configuration For Save Operation
See original GitHub issueI’m maintaining the EditorConfig extension and am in dire need of a feature that would eliminate some issues with respect to the following settings and potentially more in the future (e.g., end of line setting):
files.insertFinalNewline
files.trimFinalNewlines
files.trimTrailingWhitespace
Specifically, I need a way to short-circuit / override these settings temporarily for a file-save operation, because allowing vscode to perform any kind of trimming is destructive and either irreversible or extremely hacky to fix. It’s like asking me to unpunch someone.
Basically, I need a way to change the way that vscode does a built-in save operation on a per-file basis (which is how EditorConfig works). Pre-save TextEdits are not good enough, because whatever I do before a save could potentially be wiped out with vscode’s destructive trimming after the fact.
Another option, of course, would be to make EditorConfig a built-in feature of vscode, which I think makes all the sense in the world.
Note: these issues only surfaced after vscode introduced these editor settings, because now we have 2 things trying to do the same thing.
Related issues
- https://github.com/editorconfig/editorconfig-vscode/issues/153
- https://github.com/editorconfig/editorconfig-vscode/issues/208
- https://github.com/editorconfig/editorconfig-vscode/issues/209
- https://stackoverflow.com/questions/46069467/vs-code-does-not-insert-final-new-line-even-if-files-insertfinalnewline-is-set
Issue Analytics
- State:
- Created 5 years ago
- Reactions:28
- Comments:14 (12 by maintainers)
Top GitHub Comments
Looks like the VS Code project itself is now recommending the EditorConfig extension. Would be nice if it was prioritized adding/changing what’s needed so it can be implemented fully and accurately.
Adding @jrieken to this thread who added the API for doing something pre-save.
Yes, probably a good idea at some point.