IDEA-75502 Tab in completion replaces the whole line instead of an identifier

This commit is contained in:
peter
2011-10-14 15:26:10 +02:00
parent 49c68d2df2
commit 6fb5e52e24
5 changed files with 19 additions and 4 deletions
@@ -110,7 +110,13 @@ public class SmartCompletionDecorator extends TailTypeDecorator<LookupElement> {
@Override
public void handleInsert(InsertionContext context) {
if (getObject() instanceof PsiVariable && context.getCompletionChar() == Lookup.REPLACE_SELECT_CHAR) {
context.commitDocument();
DefaultInsertHandler.removeEndOfIdentifier(context);
context.commitDocument();
}
myPosition = getPosition(context, this);
super.handleInsert(context);
}
@@ -85,10 +85,6 @@ public class VariableLookupItem extends LookupItem<PsiVariable> implements Typed
context.getDocument().replaceString(context.getStartOffset(), context.getTailOffset(), variable.getName());
context.commitDocument();
if (context.getCompletionChar() == Lookup.REPLACE_SELECT_CHAR) {
DefaultInsertHandler.removeEndOfIdentifier(context);
context.commitDocument();
}
if (variable instanceof PsiField) {
if (willBeImported()) {
@@ -0,0 +1,6 @@
class Foo {
void foo() {
Object textIndex = null;
Object p = tI<caret>equals(2);
}
}
@@ -0,0 +1,6 @@
class Foo {
void foo() {
Object textIndex = null;
Object p = textIndex<caret>(2);
}
}
@@ -864,6 +864,7 @@ public class NormalCompletionTest extends LightFixtureCompletionTestCase {
assertEquals("fzazzz", list.get(1).getLookupString());
}
public void testTabReplacesMethodNameWithLocalVariableName() throws Throwable { doTest('\t'); }
public void testMethodParameterAnnotationClass() throws Throwable { doTest(); }
public void testPrimitiveCastOverwrite() throws Throwable { doTest '\t' }
public void testClassReferenceInFor() throws Throwable { doTest ' ' }