How can I get the path of the focused TextEditor (the one with the blinking cursor)?


I have been looking around the documentation for a way to get the file path of the focused TextEditor’s file.
I can get all the path of all the TextEditors with

for editorView in atom.workspaceView.getEditorViews()

But I can’t find a property or class that could tell me if the referenced EditorView is the one that is focused on (with the TextEditorView with a blinking cursor)

Please advise.



Atom is shifting towards using the Models for things rather than the views. So rather than using atom.workspaceView, you’ll find it easier if you go through the Workspace Model, i.e. atom.workspace:

editor = atom.workspace.getActiveTextEditor()



Thanks! That’s what I needed.


I answered his question incorrectly but my solution is a valid required one if the item is not a TextEditor. Two or three of my packages work with tab items that can be any item.