diff --git a/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupTypedHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupTypedHandler.java index b13bbb4be33e..dd370f6dfe7f 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupTypedHandler.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupTypedHandler.java @@ -59,18 +59,19 @@ public class LookupTypedHandler extends TypedActionHandlerBase { @Override public void execute(@NotNull Editor originalEditor, char charTyped, @NotNull DataContext dataContext) { final Project project = CommonDataKeys.PROJECT.getData(dataContext); - PsiFile file; + PsiFile file = project == null ? null : PsiUtilBase.getPsiFileInEditor(originalEditor, project); - if (project == null - || (file = PsiUtilBase.getPsiFileInEditor(originalEditor, project)) == null - || !CodeInsightUtilBase.prepareEditorForWrite(originalEditor) - || !FileDocumentManager.getInstance().requestWriting(originalEditor.getDocument(), project)) { + if (file == null) { if (myOriginalHandler != null){ myOriginalHandler.execute(originalEditor, charTyped, dataContext); } return; } + if (!CodeInsightUtilBase.prepareEditorForWrite(originalEditor) || !FileDocumentManager.getInstance().requestWriting(originalEditor.getDocument(), project)) { + return; + } + CompletionPhase oldPhase = CompletionServiceImpl.getCompletionPhase(); if (oldPhase instanceof CompletionPhase.CommittingDocuments && ((CompletionPhase.CommittingDocuments)oldPhase).isRestartingCompletion()) { assert oldPhase.indicator != null;