That’s one of the features that I’m missing from SL and I really got used to it… It is a great feature and I think it should be in the core settings.
It is part of the core settings. It lives in the Atom package called
Event to focus and unfocus to a tab (EditorView)?
Maybe I should go through all the packages… thanks
Problem is it saves on any pane lost focus. Would be nice if option to save on lost focus of the IDE rather than the pane itself. This is because if you’re using live reload or browser sync etc. you probably don’t want the page reloading until you’re done editing all files needed if that makes sense.
If you want to autosave only when the window loses focus, you can disable the autosave package and put the following in your
atom.getCurrentWindow().on 'blur', -> for pane in atom.workspace.getPanes() pane.saveItems()
Excellent! Exactly the desired behavior I’d like!
You could even wrap it up into your own package to publish for other people to use.
Thanks olmokramer. One slight improvement can be made: only save items that have been modified.
atom.getCurrentWindow().on 'blur', -> for pane in atom.workspace.getPanes() for item in pane.items if item.isModified and item.isModified() item.save()
One problem with this approach is that pane items that do not implement an
isModified method will never be saved. I’d change that to
if item.isModified? item.save() if item.isModified() else item.save()
This is almost perfect other than the fact that it assumes all pane items are TextEditor pane items. TextEditor pane items are the only ones that implement the save method out of the box, thus you get an error when UI tabs such as setting are open. Adding a check to see if pane items are TextEditor objects the snippet becomes
atom.getCurrentWindow().on 'blur', -> for pane in atom.workspace.getPanes() for item in pane.items if atom.workspace.isTextEditor(item) if item.isModified? item.save() if item.isModified() else item.save()