don't autopopup or restart completion in dumb mode

This commit is contained in:
peter.gromov
2010-11-11 21:03:29 +03:00
parent 99a334ae5f
commit f997b56ec5
2 changed files with 7 additions and 0 deletions
@@ -636,6 +636,7 @@ public class CompletionProgressIndicator extends ProgressIndicatorBase implement
final int offset = myEditor.getCaretModel().getOffset();
final long stamp = myEditor.getDocument().getModificationStamp();
final Project project = getProject();
final boolean wasDumb = DumbService.getInstance(project).isDumb();
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
@@ -647,6 +648,10 @@ public class CompletionProgressIndicator extends ProgressIndicatorBase implement
return;
}
if (!wasDumb && DumbService.getInstance(project).isDumb()) {
return;
}
if (myEditor.getCaretModel().getOffset() != offset || myEditor.getDocument().getModificationStamp() != stamp) {
return;
}
@@ -34,6 +34,7 @@ import com.intellij.openapi.fileEditor.FileEditorManagerAdapter;
import com.intellij.openapi.fileEditor.FileEditorManagerEvent;
import com.intellij.openapi.fileEditor.FileEditorManagerListener;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.project.DumbService;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Key;
import com.intellij.psi.PsiFile;
@@ -98,6 +99,7 @@ public class CompletionAutoPopupHandler extends TypedHandlerDelegate {
if (project.isDisposed() || !file.isValid()) return;
if (editor.isDisposed() || isMainEditor && FileEditorManager.getInstance(project).getSelectedTextEditor() != editor) return;
if (ApplicationManager.getApplication().isWriteAccessAllowed()) return; //it will fail anyway
if (DumbService.getInstance(project).isDumb()) return;
new CodeCompletionHandlerBase(CompletionType.BASIC, false, true).invoke(project, editor);