From f0beb9f456e7cfe6734724916c977f8969a11f35 Mon Sep 17 00:00:00 2001 From: Olga Strizhenko Date: Wed, 6 Sep 2017 14:19:42 +0300 Subject: [PATCH] Spellchecker: WI-36470 Spellchecking: Quick fix "Change to..." works incorrectly for injected language --- .../spellchecker/quickfixes/ShowSuggestions.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/spellchecker/src/com/intellij/spellchecker/quickfixes/ShowSuggestions.java b/spellchecker/src/com/intellij/spellchecker/quickfixes/ShowSuggestions.java index 15168c0c3296..bfaf2b314619 100644 --- a/spellchecker/src/com/intellij/spellchecker/quickfixes/ShowSuggestions.java +++ b/spellchecker/src/com/intellij/spellchecker/quickfixes/ShowSuggestions.java @@ -30,6 +30,7 @@ import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.util.List; +import static com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil.findInjectionHost; public abstract class ShowSuggestions implements LocalQuickFix, Iconable { @@ -57,10 +58,8 @@ public abstract class ShowSuggestions implements LocalQuickFix, Iconable { @Nullable protected Editor getEditor(PsiElement element, @NotNull Project project) { - Editor editor = FileEditorManager.getInstance(project).getSelectedTextEditor(); - if (InjectedLanguageUtil.findInjectionHost(element) != null) { - editor = InjectedLanguageUtil.openEditorFor(element.getContainingFile(), project); - } - return editor; + return findInjectionHost(element) != null + ? InjectedLanguageUtil.openEditorFor(element.getContainingFile(), project) + : FileEditorManager.getInstance(project).getSelectedTextEditor(); } }