From 5602cb95144dd39f61b87ca473893f532ee2f441 Mon Sep 17 00:00:00 2001 From: Alexey Pegov Date: Tue, 22 Sep 2009 15:23:14 +0400 Subject: [PATCH] IDEADEV-39235 Autoscroll from source (?project view) doesn?'?t work for image files --- .../ide/projectView/impl/ProjectViewImpl.java | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/platform/lang-impl/src/com/intellij/ide/projectView/impl/ProjectViewImpl.java b/platform/lang-impl/src/com/intellij/ide/projectView/impl/ProjectViewImpl.java index 627775bbf5..ee5285c9ac 100644 --- a/platform/lang-impl/src/com/intellij/ide/projectView/impl/ProjectViewImpl.java +++ b/platform/lang-impl/src/com/intellij/ide/projectView/impl/ProjectViewImpl.java @@ -32,6 +32,7 @@ import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.fileEditor.*; +import com.intellij.openapi.fileEditor.ex.FileEditorManagerEx; import com.intellij.openapi.module.Module; import com.intellij.openapi.project.DumbAware; import com.intellij.openapi.project.Project; @@ -1509,6 +1510,26 @@ public final class ProjectViewImpl extends ProjectView implements PersistentStat if (newEditor instanceof TextEditor) { Editor editor = ((TextEditor)newEditor).getEditor(); selectElementAtCaretNotLosingFocus(editor); + } else if (newEditor != null) { + final VirtualFile file = FileEditorManagerEx.getInstanceEx(myProject).getFile(newEditor); + if (file != null) { + final PsiFile psiFile = PsiManager.getInstance(myProject).findFile(file); + if (psiFile != null) { + final SelectInTarget target = mySelectInTargets.get(getCurrentViewId()); + if (target != null) { + final MySelectInContext selectInContext = new MySelectInContext(psiFile, null) { + @Override + public Object getSelectorInFile() { + return psiFile; + } + }; + + if (target.canSelect(selectInContext)) { + target.selectIn(selectInContext, false); + } + } + } + } } } } -- 2.11.4.GIT