Program: 73635
Project: 73635
Buggy source:
public void selectionChanged(SelectionChangedEvent event){
  boolean isContextChange=false;
  if (event.getSource() instanceof ComboViewer) {
    isContextChange=JSEditor.VIEWER_CATEGORY_CONTEXT.equals(((ComboViewer)event.getSource()).getData(JSEditor.VIEWER_CATEGORY_KEY));
  }
  ISelection selection=event.getSelection();
  if (selection != null) {
    Object[] sel=((IStructuredSelection)selection).toArray();
    if (sel.length == 1) {
      if (isContextChange) {
        editor.cmbSubFunctionsViewer.refresh();
        int itemCount=editor.cmbSubFunctions.getItemCount();
        if (itemCount > 0) {
          editor.cmbSubFunctions.select(0);
        }
        editor.cmbSubFunctions.setEnabled(itemCount > 0);
      }
 else {
        if (sel[0] instanceof IMethodInfo) {
          IMethodInfo methodInfo=(IMethodInfo)sel[0];
          String signature=createSignature(methodInfo);
          try {
            IScriptEditor viewer=editor.getScriptEditor();
            if (viewer instanceof AbstractTextEditor) {
              AbstractTextEditor editor=(AbstractTextEditor)viewer;
              IDocument doc=(editor.getDocumentProvider()).getDocument(viewer.getEditorInput());
              int length=doc.getLength();
              doc.replace(length,0,signature);
              editor.selectAndReveal(length + 1,signature.length());
            }
          }
 catch (          BadLocationException e) {
            logger.log(Level.SEVERE,e.getMessage(),e);
          }
          editor.cmbSubFunctions.select(0);
        }
      }
    }
  }
}

Fixed version (ground truth):
public void selectionChanged(SelectionChangedEvent event){
  boolean isContextChange=false;
  if (event.getSource() instanceof ComboViewer) {
    isContextChange=JSEditor.VIEWER_CATEGORY_CONTEXT.equals(((ComboViewer)event.getSource()).getData(JSEditor.VIEWER_CATEGORY_KEY));
  }
  ISelection selection=event.getSelection();
  if (selection != null) {
    Object[] sel=((IStructuredSelection)selection).toArray();
    if (sel.length == 1) {
      if (isContextChange) {
        editor.cmbSubFunctionsViewer.refresh();
        int itemCount=editor.cmbSubFunctions.getItemCount();
        if (itemCount > 0) {
          editor.cmbSubFunctions.select(0);
        }
        editor.cmbSubFunctions.setEnabled(itemCount > 0);
      }
 else {
        if (sel[0] instanceof IMethodInfo) {
          IMethodInfo methodInfo=(IMethodInfo)sel[0];
          Position pos=findMethod(methodInfo);
          if (pos != null) {
            IScriptEditor viewer=editor.getScriptEditor();
            if (viewer instanceof AbstractTextEditor) {
              AbstractTextEditor editor=(AbstractTextEditor)viewer;
              editor.selectAndReveal(pos.getOffset(),pos.length);
            }
          }
 else {
            String signature=createSignature(methodInfo);
            try {
              IScriptEditor viewer=editor.getScriptEditor();
              if (viewer instanceof AbstractTextEditor) {
                AbstractTextEditor editor=(AbstractTextEditor)viewer;
                IDocument doc=(editor.getDocumentProvider()).getDocument(viewer.getEditorInput());
                int length=doc.getLength();
                doc.replace(length,0,signature);
                editor.selectAndReveal(length + 1,signature.length());
              }
            }
 catch (            BadLocationException e) {
              logger.log(Level.SEVERE,e.getMessage(),e);
            }
          }
          editor.cmbSubFunctions.select(0);
        }
      }
    }
  }
}