Skip to content

Commit

Permalink
Insert the selected completion even when completions are blocked. (#136)
Browse files Browse the repository at this point in the history
* Insert the selected completion even when completions are blocked.

* Fix failing test.
  • Loading branch information
shaiahr authored Apr 26, 2021
1 parent 6ad06e3 commit 3ac75bd
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import com.intellij.codeInsight.daemon.impl.HintRenderer;
import com.intellij.codeInsight.lookup.LookupElement;
import com.intellij.codeInsight.lookup.LookupElementDecorator;
import com.intellij.codeInsight.lookup.LookupEvent;
import com.intellij.codeInsight.lookup.LookupListener;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.ControlFlowException;
import com.intellij.openapi.diagnostic.Logger;
Expand All @@ -29,11 +31,12 @@
* indicating the quota was exceeded. Hovering the mouse over this inlay open a balloon with more details and possibly
* CTA links.
*/
public class LimitExceededLookupElement extends InsertNothingLookupElement {
public class LimitExceededLookupElement extends LookupElementDecorator<LookupElement>
implements LookupListener {
private final BinaryRequestFacade binaryRequestFacade = DependencyContainer.instanceOfBinaryRequestFacade();

protected LimitExceededLookupElement(LookupElement delegate, String prefix) {
super(delegate, prefix);
protected LimitExceededLookupElement(LookupElement delegate) {
super(delegate);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ public void renderElement(
}
});
if (locked) {
final InsertNothingLookupElement lookupElement = new LimitExceededLookupElement(
lookupElementBuilder, oldPrefix);
final LimitExceededLookupElement lookupElement = new LimitExceededLookupElement(
lookupElementBuilder);
if (activeLookup != null) {
activeLookup.addLookupListener(lookupElement);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.intellij.codeInsight.lookup.LookupElement;
import com.tabnine.binary.exceptions.TabNineDeadException;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.mockito.stubbing.Answer;
Expand All @@ -20,6 +21,13 @@
import static org.mockito.Mockito.*;

public class BinaryBadResultsIntegrationTests extends MockedBinaryCompletionTestCase {

@Before
public void beforeEach() {
myFixture.completeBasic(); //make sure all singletons are inited
clearInvocations(binaryProcessGatewayProviderMock);
}

@Test
public void givenACompletionWhenIOExceptionWasThrownThenBinaryIsRestarted() throws Exception {
when(binaryProcessGatewayMock.readRawResponse()).thenThrow(new IOException());
Expand Down

0 comments on commit 3ac75bd

Please sign in to comment.