Program: 93164
Project: 93164
Buggy source:
private void createSearchPopup(){
  Shell parentShell=context.getViewer().getTextWidget().getShell();
  searchShell=new Shell(parentShell,SWT.ON_TOP);
  searchShell.setLayout(new FillLayout());
  searchShell.addListener(SWT.Traverse,new Listener(){
    @Override public void handleEvent(    Event e){
      if (e.detail == SWT.TRAVERSE_ESCAPE) {
        state=AssistantControlState.ENABLE_HIDE;
        assistant.uninstall();
      }
    }
  }
);
  searchText=new StyledText(searchShell,SWT.SINGLE);
  searchText.setFont(fontRegistry.get("String_Node_Str"));
  searchText.setBackground(colorRegistry.get(PREF_SEARCH_BOX_BACKGROUND));
  searchText.addFocusListener(new FocusAdapter(){
    @Override public void focusLost(    FocusEvent e){
      if (!assistant.hasProposalPopupFocus()) {
        state=AssistantControlState.ENABLE_HIDE;
        searchShell.dispose();
        assistant.uninstall();
      }
    }
  }
);
  searchText.addVerifyKeyListener(new VerifyKeyListener(){
    @Override public void verifyKey(    VerifyEvent e){
      ICompletionProposal appliedProposal=selectedProposal;
switch (e.character) {
case SWT.CR:
        e.doit=false;
      if (appliedProposal instanceof SnippetProposal) {
        SnippetProposal snippetProposal=(SnippetProposal)appliedProposal;
        state=AssistantControlState.ENABLE_HIDE;
        assistant.uninstall();
        if (snippetProposal.isValidFor(context.getDocument(),context.getInvocationOffset())) {
          snippetApplied(snippetProposal);
        }
        snippetProposal.apply(context.getViewer(),(char)0,SWT.NONE,context.getInvocationOffset());
        Point selection=snippetProposal.getSelection(context.getDocument());
        if (selection != null) {
          context.getViewer().setSelectedRange(selection.x,selection.y);
          context.getViewer().revealRange(selection.x,selection.y);
        }
      }
 else {
        state=AssistantControlState.ENABLE_HIDE;
        assistant.uninstall();
      }
    return;
case SWT.TAB:
  e.doit=false;
return;
}
if (appliedProposal == null) {
return;
}
switch (e.keyCode) {
case SWT.ARROW_UP:
execute(ContentAssistant.SELECT_PREVIOUS_PROPOSAL_COMMAND_ID);
if (selectedProposal instanceof RepositoryProposal) {
execute(ContentAssistant.SELECT_PREVIOUS_PROPOSAL_COMMAND_ID);
}
return;
case SWT.ARROW_DOWN:
execute(ContentAssistant.SELECT_NEXT_PROPOSAL_COMMAND_ID);
if (selectedProposal instanceof RepositoryProposal) {
execute(ContentAssistant.SELECT_NEXT_PROPOSAL_COMMAND_ID);
}
return;
}
}
}
);
searchText.addModifyListener(new ModifyListener(){
@Override public void modifyText(ModifyEvent e){
String query=searchText.getText().trim();
processor.setTerms(query);
assistant.showPossibleCompletions();
assistant.showContextInformation();
if (selectedProposal instanceof RepositoryProposal) {
execute(ContentAssistant.SELECT_NEXT_PROPOSAL_COMMAND_ID);
}
}
}
);
placeShell();
searchShell.open();
searchShell.setFocus();
}

Fixed version (ground truth):
private void createSearchPopup(){
  Shell parentShell=context.getViewer().getTextWidget().getShell();
  searchShell=new Shell(parentShell,SWT.ON_TOP);
  searchShell.setLayout(new FillLayout());
  searchShell.addListener(SWT.Traverse,new Listener(){
    @Override public void handleEvent(    Event e){
      if (e.detail == SWT.TRAVERSE_ESCAPE) {
        state=AssistantControlState.ENABLE_HIDE;
        assistant.uninstall();
      }
    }
  }
);
  searchText=new StyledText(searchShell,SWT.SINGLE);
  searchText.setFont(fontRegistry.get("String_Node_Str"));
  searchText.setBackground(colorRegistry.get(PREF_SEARCH_BOX_BACKGROUND));
  searchText.addFocusListener(new FocusAdapter(){
    @Override public void focusLost(    FocusEvent e){
      if (!assistant.hasProposalPopupFocus()) {
        state=AssistantControlState.ENABLE_HIDE;
        searchShell.dispose();
        assistant.uninstall();
      }
    }
  }
);
  searchText.addVerifyKeyListener(new VerifyKeyListener(){
    @Override public void verifyKey(    VerifyEvent e){
      ICompletionProposal appliedProposal=selectedProposal;
switch (e.character) {
case SWT.CR:
        e.doit=false;
      if (appliedProposal instanceof SnippetProposal) {
        SnippetProposal snippetProposal=(SnippetProposal)appliedProposal;
        state=AssistantControlState.ENABLE_HIDE;
        assistant.uninstall();
        if (snippetProposal.isValidFor(context.getDocument(),context.getInvocationOffset())) {
          snippetApplied(snippetProposal);
        }
        snippetProposal.apply(context.getViewer(),(char)0,SWT.NONE,context.getInvocationOffset());
        Point selection=snippetProposal.getSelection(context.getDocument());
        if (selection != null) {
          context.getViewer().setSelectedRange(selection.x,selection.y);
          context.getViewer().revealRange(selection.x,selection.y);
        }
      }
 else {
        state=AssistantControlState.ENABLE_HIDE;
        assistant.uninstall();
      }
    return;
case SWT.TAB:
  e.doit=false;
return;
}
if (appliedProposal == null) {
return;
}
switch (e.keyCode) {
case SWT.ARROW_UP:
execute(ContentAssistant.SELECT_PREVIOUS_PROPOSAL_COMMAND_ID);
if (selectedProposal instanceof RepositoryProposal) {
execute(ContentAssistant.SELECT_PREVIOUS_PROPOSAL_COMMAND_ID);
}
return;
case SWT.ARROW_DOWN:
execute(ContentAssistant.SELECT_NEXT_PROPOSAL_COMMAND_ID);
if (selectedProposal instanceof RepositoryProposal) {
execute(ContentAssistant.SELECT_NEXT_PROPOSAL_COMMAND_ID);
}
return;
}
}
}
);
searchText.addModifyListener(new ModifyListener(){
@Override public void modifyText(ModifyEvent e){
String query=searchText.getText().trim();
processor.setTerms(query);
assistant.setEmptyMessage(Messages.COMPLETION_ENGINE_NO_SNIPPETS_FOUND);
assistant.showPossibleCompletions();
assistant.showContextInformation();
if (selectedProposal instanceof RepositoryProposal) {
execute(ContentAssistant.SELECT_NEXT_PROPOSAL_COMMAND_ID);
}
}
}
);
placeShell();
searchShell.open();
searchShell.setFocus();
}