Open egamma opened 7 years ago
I'd rather this was handled as part of a Format Document request. Modifying a file on save isn't really a user-apparent pattern.
@RyanCavanaugh doing this as part of the getFormattingEditsForDocument
request makes good sense and it blends well with format on save support. However, what is missing, is that the request has a some context information whether it was triggered as part of a save or not. For the tslint example the user would not want auto fix on each format request but only on save.
Modifying a file on save isn't really a user-apparent pattern.
Support for 'format on save' or 'auto fix on save' are common and supported by many editors IDEs. The key is that this is done as a pre-save operation so that a file is not saved twice.
Can/should this be investigated soon?
Background angelozerr/tslint-language-service#32.
The tslint language server extension should support an option to auto fix lint rules with a fixer before a file is saved. The plugin API should support a willSave method that a plugin can use to perform an operation like auto fixing before the document is saved. In addition there needs to be request that the TypeScript language client like VS Code can use to inform the TypeScript language server that the user is about to save a file.