ask for save file before running external process ?
Answered
I'm trying to run jbang (https://jbang.dev) on a file in the current editor but since it is in an external process I don't want to run just jbang on the file as the edits in the file might not be saved yet.
What is the best practice/api to use to ensure users when calling an action that triggers external process that it gets run on the actual content - is there a a "want to save first ?" dialog or some API to call to ensure editor is not dirty ?
Please sign in to leave a comment.
Hi Max,
You can use
FileDocumentManager.getInstance().saveAllDocuments()
method before you execute an external process that works on the edited files.Will that ask before saving if auto-save turned of ? I didn't see it do that thus was not sure it was the right one :)
Hi Max,
What do you mean by turning off auto-save? It shouldn't be possible to disable it (Appearance & Behavior / System Settings / Autosave has some options for it).
IDE triggers autosave in various events, see: https://www.jetbrains.com/help/idea/2021.3/saving-and-reverting-changes.html and I think it is a good approach to invoke the saveAllDocuments() method before you run an external process.