From 8234e6051bd05b7b86f50b6d82f8f446f242fc2c Mon Sep 17 00:00:00 2001 From: Aleksey Pivovarov Date: Thu, 26 Oct 2017 15:39:07 +0300 Subject: [PATCH] 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 0535e6ebb2affc0f9ee646e8785bf15eff8dd469 --- .../src/com/intellij/ide/util/FileStructurePopup.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/platform/lang-impl/src/com/intellij/ide/util/FileStructurePopup.java b/platform/lang-impl/src/com/intellij/ide/util/FileStructurePopup.java index b8c423483617..fdfd7f4f9079 100644 --- a/platform/lang-impl/src/com/intellij/ide/util/FileStructurePopup.java +++ b/platform/lang-impl/src/com/intellij/ide/util/FileStructurePopup.java @@ -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 {