Detect when any open tab's title changes?


#1

I am looking for a reliable way to determine when any tab’s title changes (from a rename or move). This could be the active tab or an inactive tab.


#2

This might work …

http://help.dottoro.com/ljrmcldi.php


#3

Not tested, but something like this should work

atom.workspace.observeTextEditors (editor) ->
  editor.on 'path-changed', ->
    # Do whatever you want...

There’s also a title-changed event, but it’s my understanding that they behave identically (fired when the buffer’s path changes).


#4

Thanks that worked well. Only question now is how do we make sure we have our package.json pointing to the correct version of the atom engine. The default is v0.50.0 but atom is at like 0.125.0 now and I am pretty sure observeTextEditors came along more recently (along with getTextEditors)… I am struggling to find out when certain methods and classes were added so I can make sure I use the right engine.


#5

The core team is working hard to reach an API freeze, so after that there will be less of a moving target. No breaking changes unless Atom gets a major version bump. For the time being though, just keep updating your package.json to whatever the latest release is, if you want to guarantee API compatibility.