IDEA-67272

This commit is contained in:
Alexey Kudravtsev
2011-04-05 17:54:05 +04:00
parent 36ddf69d50
commit 3e532eec44
3 changed files with 18 additions and 4 deletions
@@ -32,7 +32,10 @@ import com.intellij.openapi.actionSystem.IdeActions;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.EditorFactory;
import com.intellij.openapi.editor.VisualPosition;
import com.intellij.openapi.editor.event.EditorFactoryAdapter;
import com.intellij.openapi.editor.event.EditorFactoryEvent;
import com.intellij.openapi.keymap.KeymapUtil;
import com.intellij.openapi.options.ShowSettingsUtil;
import com.intellij.openapi.project.Project;
@@ -260,7 +263,9 @@ public class IntentionHintComponent extends JPanel implements Disposable, Scroll
return new Point(location.x, location.y);
}
private IntentionHintComponent(@NotNull Project project, @NotNull PsiFile file, @NotNull final Editor editor,
private IntentionHintComponent(@NotNull Project project,
@NotNull PsiFile file,
@NotNull final Editor editor,
@NotNull ShowIntentionsPass.IntentionsInfo intentions) {
ApplicationManager.getApplication().assertReadAccessAllowed();
myFile = file;
@@ -317,6 +322,15 @@ public class IntentionHintComponent extends JPanel implements Disposable, Scroll
myComponentHint = new MyComponentHint(this);
IntentionListStep step = new IntentionListStep(this, intentions, myEditor, myFile, project);
recreateMyPopup(step);
// dispose myself when editor closed
EditorFactory.getInstance().addEditorFactoryListener(new EditorFactoryAdapter() {
@Override
public void editorReleased(EditorFactoryEvent event) {
if (event.getEditor() == myEditor) {
hide();
}
}
}, this);
}
public void hide() {
@@ -150,7 +150,7 @@ public class InjectedLanguageUtil {
@NotNull
public static Editor getInjectedEditorForInjectedFile(@NotNull Editor hostEditor, final PsiFile injectedFile) {
if (injectedFile == null || hostEditor instanceof EditorWindow) return hostEditor;
if (injectedFile == null || hostEditor instanceof EditorWindow || hostEditor.isDisposed()) return hostEditor;
Document document = PsiDocumentManager.getInstance(hostEditor.getProject()).getDocument(injectedFile);
if (!(document instanceof DocumentWindowImpl)) return hostEditor;
DocumentWindowImpl documentWindow = (DocumentWindowImpl)document;
@@ -370,7 +370,7 @@ public class InjectedLanguageUtil {
virtualFile = ((VirtualFileWindow)virtualFile).getDelegate();
}
Editor editor = FileEditorManager.getInstance(project).openTextEditor(new OpenFileDescriptor(project, virtualFile, -1), false);
if (editor == null || editor instanceof EditorWindow) return editor;
if (editor == null || editor instanceof EditorWindow || editor.isDisposed()) return editor;
if (document instanceof DocumentWindowImpl) {
return EditorWindow.create((DocumentWindowImpl)document, (EditorImpl)editor, file);
}
@@ -628,7 +628,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
if (myConnection != null) {
myConnection.disconnect();
}
}
}
private void clearCaretThread() {