autopopup sometimes showed no suggestions

This commit is contained in:
peter
2011-02-07 12:49:28 +01:00
parent a92e8b744a
commit 2f90c39631
3 changed files with 25 additions and 8 deletions
@@ -460,5 +460,21 @@ class JavaAutoPopupTest extends CompletionAutoPopupTestCase {
assert lookup
}
public void testHideOnInvalidSymbolAfterBackspace() {
myFixture.configureByText("a.java", """
class A {
Object foo() { this<caret> }
}
""")
type '.'
assert lookup
type 'c'
assert lookup
type '\b'
assert lookup
type 'x'
assert !lookup
}
}
@@ -16,9 +16,8 @@
package com.intellij.codeInsight.lookup.impl;
import com.intellij.codeInsight.completion.CompletionProcess;
import com.intellij.codeInsight.completion.CompletionProgressIndicator;
import com.intellij.codeInsight.completion.CompletionService;
import com.intellij.codeInsight.completion.impl.CompletionServiceImpl;
import com.intellij.codeInsight.lookup.LookupManager;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor;
@@ -45,14 +44,14 @@ public class BackspaceHandler extends EditorActionHandler {
}
});
if (lookup.truncatePrefix()) {
final CompletionProgressIndicator process = CompletionServiceImpl.getCompletionService().getCurrentCompletion();
if (lookup.truncatePrefix(process == null || !process.isAutopopupCompletion())) {
return;
}
if (lookup.getLookupStart() < editor.getCaretModel().getOffset()) {
final CompletionProcess process = CompletionService.getCompletionService().getCurrentCompletion();
if (process instanceof CompletionProgressIndicator) {
((CompletionProgressIndicator)process).scheduleRestart();
if (process != null) {
process.scheduleRestart();
return;
}
}
@@ -317,11 +317,13 @@ public class LookupImpl extends LightweightHint implements Lookup, Disposable {
ListScrollingUtil.ensureIndexIsVisible(myList, myList.getSelectedIndex(), 1);
}
public boolean truncatePrefix() {
public boolean truncatePrefix(boolean preserveSelection) {
final int len = myAdditionalPrefix.length();
if (len == 0) return false;
markSelectionTouched();
if (preserveSelection) {
markSelectionTouched();
}
myAdditionalPrefix = myAdditionalPrefix.substring(0, len - 1);
myInitialPrefix = null;