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

Consider adding config param to opt-out of `rust.actionOnSave` being affected by Auto Save

Open redactedscribe opened this issue 8 years ago • 7 comments
trafficstars

Version of the extension: 0.3.10

The extension could check if the file was saved manually as opposed to by File > Auto Save. When set to save automatically via the File menu, "files.autoSave": "afterDelay" is set. This triggers rust.actionOnSave each time after the default "files.autoSaveDelay": 1000.

"afterDelay" for files.autoSave is not particularly useful for *.rs files when rust.actionOnSave has been set to "build" etc.

Perhaps a configuration parameter such as "rust.actionOnSaveIgnoreAutoSave": <boolean> could be introduced to opt-out of rust.actionOnSave being triggered by an Auto Save. This way, people choosing to use Auto Save, can still use it for other non-*.rs files in their project. If "rust.actionOnSave": null, then Auto Save should still work for *.rs files.

According to the VS Code API, one could use onWillSaveTextDocument instead of onDidSaveTextDocument and use TextDocumentSaveReason to check it was a manual save or not.

redactedscribe avatar Mar 03 '17 21:03 redactedscribe

@redactedscribe, I didn't know that Action On Save is executed if a file saved automatically. I will check if it is. If it is, I will disable Action On Save because that's what behavior is correct. People want to execute Action On Save when they save, not the program.

KalitaAlexey avatar Mar 04 '17 07:03 KalitaAlexey

If anyone disagrees with my opinion, speak up.

KalitaAlexey avatar Mar 04 '17 07:03 KalitaAlexey

This issue and #138 (actionOnSave does not trigger when saving and file is clean) lead to the tricky situation. If we changed Action On Save not to execute on saving automatically and kept the current behavior of Action On Save if all files are clean, the user would have to execute a command from the command palette manually. I like this decision as it leads to none of problems.

KalitaAlexey avatar Mar 04 '17 07:03 KalitaAlexey

People want to execute Action On Save when they save, not the program.

I understand what you mean. But ultimately it's not the program that saves, the user has chosen to enable Auto Save and may want to use that combined with actionOnSave. I think people would assume Auto Save to trigger actionOnSave, so they may not understand why it's not triggering. This why I suggested an opt-out feature to disable Auto Save triggering the action. With this feature implemented, I would personally opt-out. How many others would opt-out? I don't know. It could also be opt-in but that may or may not be intuitive, depends on people's perspective.

I don't think there is a rush to fix this, so it could wait.

redactedscribe avatar Mar 04 '17 17:03 redactedscribe

Let's hear other people opinions.

KalitaAlexey avatar Mar 04 '17 17:03 KalitaAlexey

Good idea.

redactedscribe avatar Mar 04 '17 18:03 redactedscribe

I found it quite surprising. Just my 2c.

Eh2406 avatar Apr 17 '17 22:04 Eh2406