Editor.onDidSave not fired when file is saved



I try to create a package which runs the python unit tests every time any file has been saved.
I thought listening to that event (https://atom.io/docs/api/v1.2.4/TextEditor#instance-onDidSave) would be the right place.
But if I use the following simple code in a new package:

activate: (state) ->
    @myFirstTestPackageView = new MyFirstTestPackageView(state.myFirstTestPackageViewState)
    @modalPanel = atom.workspace.addModalPanel(item: @myFirstTestPackageView.getElement(), visible: false)

    # Events subscribed to in atom's system can be easily cleaned up with a CompositeDisposable
    @subscriptions = new CompositeDisposable

    # Register command that toggles this view
    @subscriptions.add atom.commands.add 'atom-workspace', 'my-first-test-package:toggle': => @toggle()

    atom.workspace.observeTextEditors (editor) ->
      editor.onDidSave >
        atom.notifications.addInfo "Saved! #{editor.getPath()}"

The notifications pop up only if I open a new editor by open a new file or by open an existing file.
They don’t show up if change a file and save that file although that would be the moment where I expect the ondidsave event to fire.

Any help is much appreciated.

It’s my first try to create an atom package and I am not familiar with coffee script, so please expect any newbie mistakes. :slightly_smiling:



I’m not sure if this editor.onDidSave > is a typo in your actual code or just in the code you posted here … but it should be -> not >.

Also, which version of Atom are you using? You linked to the documentation for v1.2.4, which is somewhat outdated.


Thanks. My typo was the mistake. Replacing > with -> worked.

I am using the current Atom version 1.3.2 but this part of the documentation seems to remain unchanged anyway.