mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
don't focus lookup until all variants have been computed
This commit is contained in:
+5
-4
@@ -234,7 +234,7 @@ public class CodeCompletionHandlerBase implements CodeInsightActionHandler {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private LookupImpl obtainLookup(Editor editor, CompletionParameters parameters) {
|
||||
private LookupImpl obtainLookup(Editor editor) {
|
||||
LookupImpl existing = (LookupImpl)LookupManager.getActiveLookup(editor);
|
||||
if (existing != null && existing.isCompletion()) {
|
||||
existing.markReused();
|
||||
@@ -251,7 +251,7 @@ public class CodeCompletionHandlerBase implements CodeInsightActionHandler {
|
||||
lookup.setResizable(false);
|
||||
lookup.setForceLightweightPopup(false);
|
||||
}
|
||||
lookup.setFocused(shouldFocusLookup(parameters));
|
||||
lookup.setFocused(!autopopup);
|
||||
return lookup;
|
||||
}
|
||||
|
||||
@@ -263,7 +263,7 @@ public class CodeCompletionHandlerBase implements CodeInsightActionHandler {
|
||||
|
||||
final CompletionParameters parameters = createCompletionParameters(invocationCount, initContext);
|
||||
|
||||
final LookupImpl lookup = obtainLookup(editor, parameters);
|
||||
final LookupImpl lookup = obtainLookup(editor);
|
||||
|
||||
final Semaphore freezeSemaphore = new Semaphore();
|
||||
freezeSemaphore.down();
|
||||
@@ -295,7 +295,7 @@ public class CodeCompletionHandlerBase implements CodeInsightActionHandler {
|
||||
indicator.showLookup();
|
||||
}
|
||||
|
||||
private static AtomicReference<LookupElement[]> startCompletionThread(final CompletionParameters parameters,
|
||||
private AtomicReference<LookupElement[]> startCompletionThread(final CompletionParameters parameters,
|
||||
final CompletionProgressIndicator indicator,
|
||||
final CompletionInitializationContext initContext) {
|
||||
|
||||
@@ -316,6 +316,7 @@ public class CodeCompletionHandlerBase implements CodeInsightActionHandler {
|
||||
ApplicationManager.getApplication().runReadAction(new Runnable() {
|
||||
public void run() {
|
||||
startSemaphore.up();
|
||||
indicator.setFocusLookupWhenDone(autopopup && shouldFocusLookup(parameters));
|
||||
indicator.duringCompletion(initContext);
|
||||
}
|
||||
});
|
||||
|
||||
+11
@@ -122,6 +122,7 @@ public class CompletionProgressIndicator extends ProgressIndicatorBase implement
|
||||
}
|
||||
};
|
||||
private final Semaphore myDuringCompletionSemaphore = new Semaphore();
|
||||
private volatile boolean myFocusLookupWhenDone;
|
||||
|
||||
public CompletionProgressIndicator(final Editor editor, CompletionParameters parameters, CodeCompletionHandlerBase handler, Semaphore freezeSemaphore,
|
||||
final OffsetMap offsetMap, LookupImpl lookup) {
|
||||
@@ -203,6 +204,10 @@ public class CompletionProgressIndicator extends ProgressIndicatorBase implement
|
||||
myDuringCompletionSemaphore.waitFor();
|
||||
}
|
||||
|
||||
public void setFocusLookupWhenDone(boolean focusLookup) {
|
||||
myFocusLookupWhenDone = focusLookup;
|
||||
}
|
||||
|
||||
private static int findReplacementOffset(int selectionEndOffset, PsiReference reference) {
|
||||
final List<TextRange> ranges = ReferenceRange.getAbsoluteRanges(reference);
|
||||
for (TextRange range : ranges) {
|
||||
@@ -381,6 +386,9 @@ public class CompletionProgressIndicator extends ProgressIndicatorBase implement
|
||||
myLookup.show();
|
||||
}
|
||||
myLookup.refreshUi();
|
||||
if (!ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
LOG.assertTrue(myLookup.isVisible());
|
||||
}
|
||||
}
|
||||
|
||||
final boolean isInsideIdentifier() {
|
||||
@@ -500,6 +508,9 @@ public class CompletionProgressIndicator extends ProgressIndicatorBase implement
|
||||
myHandler.handleEmptyLookup(getProject(), myEditor, myParameters, CompletionProgressIndicator.this);
|
||||
}
|
||||
} else {
|
||||
if (myFocusLookupWhenDone) {
|
||||
myLookup.setFocused(true);
|
||||
}
|
||||
updateLookup();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user