mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
don't close lookup on appending prefix during completion
This commit is contained in:
@@ -316,4 +316,19 @@ class JavaAutoPopupTest extends CompletionAutoPopupTestCase {
|
||||
assert 'ArrayIndexOutOfBoundsException' in myFixture.lookupElementStrings
|
||||
}
|
||||
|
||||
public void testTypingDuringExplicitCompletion() {
|
||||
myFixture.configureByText("a.java", """
|
||||
class A {
|
||||
{ Runnable r = new <caret> }
|
||||
}
|
||||
""")
|
||||
myFixture.complete CompletionType.SMART
|
||||
edt { myFixture.type 'Thr' }
|
||||
joinCompletion()
|
||||
assert lookup
|
||||
assert 'Thread' in myFixture.lookupElementStrings
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -285,7 +285,7 @@ public class CodeCompletionHandlerBase implements CodeInsightActionHandler {
|
||||
|
||||
final AtomicReference<LookupElement[]> data = startCompletionThread(parameters, indicator, initContext);
|
||||
|
||||
if (!invokedExplicitly && (!ApplicationManager.getApplication().isUnitTestMode() || CompletionAutoPopupHandler.ourTestingAutopopup)) {
|
||||
if ((!invokedExplicitly && !ApplicationManager.getApplication().isUnitTestMode()) || CompletionAutoPopupHandler.ourTestingAutopopup) {
|
||||
indicator.notifyBackgrounded();
|
||||
return;
|
||||
}
|
||||
|
||||
+19
-11
@@ -401,16 +401,14 @@ public class CompletionProgressIndicator extends ProgressIndicatorBase implement
|
||||
LOG.assertTrue(this == CompletionServiceImpl.getCompletionService().getCurrentCompletion());
|
||||
|
||||
Lookup lookup = LookupManager.getActiveLookup(myEditor);
|
||||
if (lookup != null) {
|
||||
LOG.assertTrue(lookup == myLookup);
|
||||
myLookup.removeLookupListener(myLookupListener);
|
||||
finishCompletionProcess();
|
||||
LOG.assertTrue(lookup == myLookup);
|
||||
myLookup.removeLookupListener(myLookupListener);
|
||||
finishCompletionProcess();
|
||||
myState.assertDisposed();
|
||||
CompletionServiceImpl.assertPhase(CompletionPhase.NoCompletion.getClass());
|
||||
|
||||
if (hideLookup) {
|
||||
LookupManager.getInstance(getProject()).hideActiveLookup();
|
||||
}
|
||||
} else {
|
||||
myState.assertDisposed();
|
||||
if (hideLookup) {
|
||||
LookupManager.getInstance(getProject()).hideActiveLookup();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -451,10 +449,19 @@ public class CompletionProgressIndicator extends ProgressIndicatorBase implement
|
||||
public void run() {
|
||||
if (isOutdated()) return;
|
||||
if (!isBackgrounded()) return;
|
||||
if (isCanceled() && !myState.isRestartScheduled()) return;
|
||||
|
||||
if (isCanceled() && myState.isRestartScheduled()) {
|
||||
CompletionServiceImpl.assertPhase(CompletionPhase.Restarted.class);
|
||||
return;
|
||||
}
|
||||
|
||||
myLookup.setCalculating(false);
|
||||
|
||||
if (isCanceled()) {
|
||||
CompletionServiceImpl.assertPhase(CompletionPhase.NoCompletion.getClass());
|
||||
return;
|
||||
}
|
||||
|
||||
if (CompletionServiceImpl.isPhase(CompletionPhase.BgCalculation.class) && hideAutopopupIfMeaningless()) {
|
||||
return;
|
||||
}
|
||||
@@ -466,7 +473,8 @@ public class CompletionProgressIndicator extends ProgressIndicatorBase implement
|
||||
final CompletionProgressIndicator current = CompletionServiceImpl.getCompletionService().getCurrentCompletion();
|
||||
LOG.assertTrue(current == null, current + "!=" + CompletionProgressIndicator.this);
|
||||
|
||||
CompletionServiceImpl.setCompletionPhase(myHandler.handleEmptyLookup(getProject(), myEditor, myParameters, CompletionProgressIndicator.this));
|
||||
CompletionServiceImpl
|
||||
.setCompletionPhase(myHandler.handleEmptyLookup(getProject(), myEditor, myParameters, CompletionProgressIndicator.this));
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
+31
-23
@@ -54,6 +54,7 @@ import com.intellij.openapi.actionSystem.Presentation;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.application.Result;
|
||||
import com.intellij.openapi.command.CommandProcessor;
|
||||
import com.intellij.openapi.command.WriteCommandAction;
|
||||
import com.intellij.openapi.editor.*;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorActionHandler;
|
||||
@@ -839,35 +840,42 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig
|
||||
public LookupElement[] complete(final CompletionType type, final int invocationCount) {
|
||||
assertInitialized();
|
||||
myEmptyLookup = false;
|
||||
new WriteCommandAction(getProject()) {
|
||||
UIUtil.invokeAndWaitIfNeeded(new Runnable() {
|
||||
@Override
|
||||
protected void run(Result result) throws Exception {
|
||||
final CodeCompletionHandlerBase handler = new CodeCompletionHandlerBase(type) {
|
||||
public void run() {
|
||||
CommandProcessor.getInstance().executeCommand(getProject(), new Runnable() {
|
||||
@Override
|
||||
protected PsiFile createFileCopy(final PsiFile file) {
|
||||
final PsiFile copy = super.createFileCopy(file);
|
||||
if (myFileContext != null) {
|
||||
final PsiElement contextCopy = myFileContext.copy();
|
||||
final PsiFile containingFile = contextCopy.getContainingFile();
|
||||
if (containingFile instanceof PsiFileImpl) {
|
||||
((PsiFileImpl)containingFile).setOriginalFile(myFileContext.getContainingFile());
|
||||
public void run() {
|
||||
final CodeCompletionHandlerBase handler = new CodeCompletionHandlerBase(type) {
|
||||
@Override
|
||||
protected PsiFile createFileCopy(final PsiFile file) {
|
||||
final PsiFile copy = super.createFileCopy(file);
|
||||
if (myFileContext != null) {
|
||||
final PsiElement contextCopy = myFileContext.copy();
|
||||
final PsiFile containingFile = contextCopy.getContainingFile();
|
||||
if (containingFile instanceof PsiFileImpl) {
|
||||
((PsiFileImpl)containingFile).setOriginalFile(myFileContext.getContainingFile());
|
||||
}
|
||||
setContext(copy, contextCopy);
|
||||
}
|
||||
return copy;
|
||||
}
|
||||
setContext(copy, contextCopy);
|
||||
}
|
||||
return copy;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void completionFinished(final int offset1, final int offset2, final CompletionProgressIndicator indicator,
|
||||
final LookupElement[] items) {
|
||||
myEmptyLookup = items.length == 0;
|
||||
super.completionFinished(offset1, offset2, indicator, items);
|
||||
@Override
|
||||
protected void completionFinished(final int offset1, final int offset2, final CompletionProgressIndicator indicator,
|
||||
final LookupElement[] items) {
|
||||
myEmptyLookup = items.length == 0;
|
||||
super.completionFinished(offset1, offset2, indicator, items);
|
||||
}
|
||||
};
|
||||
Editor editor = getCompletionEditor();
|
||||
handler.invokeCompletion(getProject(), editor, PsiUtilBase.getPsiFileInEditor(editor, getProject()), invocationCount);
|
||||
|
||||
}
|
||||
};
|
||||
Editor editor = getCompletionEditor();
|
||||
handler.invokeCompletion(getProject(), editor, PsiUtilBase.getPsiFileInEditor(editor, getProject()), invocationCount);
|
||||
}, null, null);
|
||||
}
|
||||
}.execute();
|
||||
});
|
||||
|
||||
return getLookupElements();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user