From ca6951a3bc613094f508483834433d22cc5c8e06 Mon Sep 17 00:00:00 2001 From: peter Date: Fri, 7 Nov 2014 11:46:34 +0100 Subject: [PATCH] IDEA-132454 "Clear Read-Only Status" dialog displayed twice on cancel --- .../codeInsight/lookup/impl/LookupTypedHandler.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) 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;