diff --git a/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupImpl.java b/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupImpl.java index c241371e2819..72ef454026b1 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupImpl.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupImpl.java @@ -600,13 +600,14 @@ public class LookupImpl extends LightweightHint implements LookupEx, Disposable } final PsiFile file = getPsiFile(); - if (file != null && !WriteCommandAction.ensureFilesWritable(myProject, Arrays.asList(file))) { - doHide(false, true); - fireItemSelected(null, completionChar); + boolean writableOk = file == null || WriteCommandAction.ensureFilesWritable(myProject, Arrays.asList(file)); + if (myDisposed) { // ensureFilesWritable could close us by showing a dialog return; } - if (myDisposed) { // ensureFilesWritable could close us by showing a dialog + if (!writableOk) { + doHide(false, true); + fireItemSelected(null, completionChar); return; }