From 8ed6636744cbed7d6ef5201b3594bd7efd995d44 Mon Sep 17 00:00:00 2001 From: Olga Strizhenko Date: Tue, 5 Sep 2017 17:37:58 +0300 Subject: [PATCH] Spellchecker: WI-36470 Spellchecking: Quick fix "Change to..." works incorrectly for injected language - replace editor from focus by selected text editor --- .../spellchecker/quickfixes/ShowSuggestions.java | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/spellchecker/src/com/intellij/spellchecker/quickfixes/ShowSuggestions.java b/spellchecker/src/com/intellij/spellchecker/quickfixes/ShowSuggestions.java index 33e2be8afa50..15168c0c3296 100644 --- a/spellchecker/src/com/intellij/spellchecker/quickfixes/ShowSuggestions.java +++ b/spellchecker/src/com/intellij/spellchecker/quickfixes/ShowSuggestions.java @@ -17,7 +17,7 @@ package com.intellij.spellchecker.quickfixes; import com.intellij.codeInspection.LocalQuickFix; import com.intellij.openapi.editor.Editor; -import com.intellij.openapi.editor.impl.EditorComponentImpl; +import com.intellij.openapi.fileEditor.FileEditorManager; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Iconable; import com.intellij.psi.PsiElement; @@ -28,7 +28,6 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; -import java.awt.*; import java.util.List; @@ -58,19 +57,10 @@ public abstract class ShowSuggestions implements LocalQuickFix, Iconable { @Nullable protected Editor getEditor(PsiElement element, @NotNull Project project) { - Editor editor = getEditorFromFocus(); - if (editor == null) { + Editor editor = FileEditorManager.getInstance(project).getSelectedTextEditor(); + if (InjectedLanguageUtil.findInjectionHost(element) != null) { editor = InjectedLanguageUtil.openEditorFor(element.getContainingFile(), project); } return editor; } - - @Nullable - private static Editor getEditorFromFocus() { - final Component c = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner(); - if (c instanceof EditorComponentImpl) { - return ((EditorComponentImpl)c).getEditor(); - } - return null; - } }