IDEA-172735 file structure: navigate in context editor if it exists

* ex: prefer to navigate in current "Preview" or "Diff" editor
  over opening new editor tab for this file

re-apply fix from 0535e6ebb2
This commit is contained in:
Aleksey Pivovarov
2017-10-26 15:45:55 +03:00
parent 136f18266e
commit 8234e6051b
@@ -40,6 +40,7 @@ import com.intellij.openapi.application.ReadAction;
import com.intellij.openapi.command.CommandProcessor;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.fileEditor.FileEditor;
import com.intellij.openapi.fileEditor.OpenFileDescriptor;
import com.intellij.openapi.fileEditor.TextEditor;
import com.intellij.openapi.fileEditor.ex.IdeDocumentHistory;
import com.intellij.openapi.ide.CopyPasteManager;
@@ -635,6 +636,11 @@ public class FileStructurePopup implements Disposable, TreeActionsOwner {
if (PlatformDataKeys.FILE_EDITOR.is(dataId)) {
return myFileEditor;
}
if (OpenFileDescriptor.NAVIGATE_IN_EDITOR.is(dataId)) {
if (myFileEditor instanceof TextEditor) {
return ((TextEditor)myFileEditor).getEditor();
}
}
if (CommonDataKeys.PSI_ELEMENT.is(dataId)) {
return getSelectedElements().filter(PsiElement.class).first();
}
@@ -744,8 +750,8 @@ public class FileStructurePopup implements Disposable, TreeActionsOwner {
commandProcessor.executeCommand(myProject, () -> {
if (selectedNode != null) {
if (selectedNode.canNavigateToSource()) {
myPopup.cancel();
selectedNode.navigate(true);
myPopup.cancel();
succeeded.set(true);
}
else {