Find previously focused editor from Toolwindow?

When the user has a tool window open, ESC will take them back to the previously-focused editor. Is it possible to figure out which editor or file that is while they still have the tool window focused?

2 comments
Comment actions Permalink

You can find corresponding logic in ToolWindowManagerImpl.appendRequestFocusInEditorComponentCmd. It's doing approximately the following:

Window window = WindowManagerEx.getInstanceEx().getMostRecentFocusedWindow();
EditorSplitters splitters = FileEditorManagerEx.getInstanceEx(project).getSplittersFor(window);
EditorWindow window = splitters.getCurrentWindow();
EditorWithProviderComposite composite = window.getSelectedEditor();
VirtualFile file = composite.getFile();
FileEditor editor = composite.getSelectedEditor();

 

0

Please sign in to leave a comment.