Opening a file (from ctrl-p fuzzy search) in the same tab of the current pane


F.e., I’d like to press ctrl+p then find a file, and replace the current file with it. I’d like it to work no matter which tab of which pane I am in.

I found an attempted solution, but it only works with one pane (not with split panes).

I wonder how to make this work well.


I don’t think it’s as simple to do it from as the attempted solution tries to do. Atom doesn’t distinguish between pane items that have focus and panels that have focus, so the only way to find the precise tab that was focused is to access the previouslyFocusedItem property on the view spawned by the package. You’ll have to locate the JS representation of the panel, potentially through atom.workspace.getModalPanels().

An alternative solution would be to edit the fuzzy-finder package itself to include a separate confirm command, potentially bound to ctrl-enter or shift-enter by default, since it might be the case that more people than yourself would benefit from a feature like this.


It’s possible to press cmd-p while focus is on the tree view, or something else, so seems like previouslyFocusedItem may not be useful in some cases. I don’t think I have time at the moment to make this happen, I’ll have to settle with using the mouse for now.


True, but you can also fall back to atom.workspace.getActiveTextEditor() if previouslyFocusedItem isn’t a TextEditor. Or maybe you just want to use atom.workspace.getActiveTextEditor().