mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-05 01:50:56 +07:00
autopopup after . is also an autopopup and should track editor events
This commit is contained in:
@@ -444,4 +444,21 @@ class JavaAutoPopupTest extends CompletionAutoPopupTestCase {
|
||||
assert !lookup
|
||||
}
|
||||
|
||||
public void testResumeAfterBackspace() {
|
||||
myFixture.configureByText("a.java", """
|
||||
class A {
|
||||
Object foo() { this<caret> }
|
||||
}
|
||||
""")
|
||||
type '.'
|
||||
assert lookup
|
||||
type 'a'
|
||||
assert !lookup
|
||||
type '\b'
|
||||
assert !lookup
|
||||
type 'c'
|
||||
assert lookup
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -16,9 +16,7 @@
|
||||
|
||||
package com.intellij.codeInsight;
|
||||
|
||||
import com.intellij.codeInsight.completion.CodeCompletionHandlerBase;
|
||||
import com.intellij.codeInsight.completion.CompletionProgressIndicator;
|
||||
import com.intellij.codeInsight.completion.CompletionType;
|
||||
import com.intellij.codeInsight.completion.impl.CompletionServiceImpl;
|
||||
import com.intellij.codeInsight.editorActions.CompletionAutoPopupHandler;
|
||||
import com.intellij.codeInsight.hint.ShowParameterInfoHandler;
|
||||
@@ -101,7 +99,7 @@ public class AutoPopupController implements Disposable {
|
||||
if (!file.isValid()) return;
|
||||
|
||||
if (condition != null && !condition.value(file)) return;
|
||||
new CodeCompletionHandlerBase(CompletionType.BASIC, false, true).invoke(myProject, editor, file);
|
||||
CompletionAutoPopupHandler.invokeAutoPopupCompletion(myProject, editor);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -112,37 +112,41 @@ public class CompletionAutoPopupHandler extends TypedHandlerDelegate {
|
||||
if (ApplicationManager.getApplication().isWriteAccessAllowed()) return; //it will fail anyway
|
||||
if (DumbService.getInstance(project).isDumb()) return;
|
||||
|
||||
new CodeCompletionHandlerBase(CompletionType.BASIC, false, true).invoke(project, editor);
|
||||
|
||||
final AutoPopupState state = new AutoPopupState(project, editor);
|
||||
editor.putUserData(STATE_KEY, state);
|
||||
|
||||
final Lookup lookup = LookupManager.getActiveLookup(editor);
|
||||
if (lookup != null) {
|
||||
lookup.addLookupListener(new LookupAdapter() {
|
||||
@Override
|
||||
public void itemSelected(LookupEvent event) {
|
||||
final AutoPopupState state = getAutoPopupState(editor);
|
||||
if (state != null) {
|
||||
state.stopAutoPopup();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void lookupCanceled(LookupEvent event) {
|
||||
final AutoPopupState state = getAutoPopupState(editor);
|
||||
if (event.isCanceledExplicitly() && state != null) {
|
||||
state.stopAutoPopup();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
invokeAutoPopupCompletion(project, editor);
|
||||
}
|
||||
};
|
||||
AutoPopupController.getInstance(project).invokeAutoPopupRunnable(request, CodeInsightSettings.getInstance().AUTO_LOOKUP_DELAY);
|
||||
return Result.STOP;
|
||||
}
|
||||
|
||||
public static void invokeAutoPopupCompletion(Project project, final Editor editor) {
|
||||
new CodeCompletionHandlerBase(CompletionType.BASIC, false, true).invoke(project, editor);
|
||||
|
||||
final AutoPopupState state = new AutoPopupState(project, editor);
|
||||
editor.putUserData(STATE_KEY, state);
|
||||
|
||||
final Lookup lookup = LookupManager.getActiveLookup(editor);
|
||||
if (lookup != null) {
|
||||
lookup.addLookupListener(new LookupAdapter() {
|
||||
@Override
|
||||
public void itemSelected(LookupEvent event) {
|
||||
final AutoPopupState state = getAutoPopupState(editor);
|
||||
if (state != null) {
|
||||
state.stopAutoPopup();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void lookupCanceled(LookupEvent event) {
|
||||
final AutoPopupState state = getAutoPopupState(editor);
|
||||
if (event.isCanceledExplicitly() && state != null) {
|
||||
state.stopAutoPopup();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static AutoPopupState getAutoPopupState(Editor editor) {
|
||||
return editor.getUserData(STATE_KEY);
|
||||
|
||||
Reference in New Issue
Block a user