nus-yam/ex-repair huggingface dataset:
Program: 193
Project: 193
Buggy source:
/** 
 * This does the actual joining of the lines
 * @param editor    The editor to join the lines in
 * @param startLine The starting logical line
 * @param count     The number of lines to join including startLine
 * @param spaces    If true the joined lines will have one space between them and any leading space on the second linewill be removed. If false, only the newline is removed to join the lines.
 * @return true if able to join the lines, false if not
 */
private boolean deleteJoinNLines(@NotNull Editor editor,int startLine,int count,boolean spaces){
  MotionGroup.moveCaret(editor,VimPlugin.getMotion().moveCaretToLineEnd(editor,startLine,true));
  for (int i=1; i < count; i++) {
    int start=VimPlugin.getMotion().moveCaretToLineEnd(editor);
    MotionGroup.moveCaret(editor,start);
    int offset;
    if (spaces) {
      offset=VimPlugin.getMotion().moveCaretToLineStartSkipLeadingOffset(editor,1);
    }
 else {
      offset=VimPlugin.getMotion().moveCaretToLineStartOffset(editor);
    }
    deleteText(editor,new TextRange(editor.getCaretModel().getOffset(),offset),null);
    if (spaces) {
      insertText(editor,start,"String_Node_Str");
      MotionGroup.moveCaret(editor,VimPlugin.getMotion().moveCaretHorizontal(editor,-1,false));
    }
  }
  return true;
}

Fixed version (ground truth):
/** 
 * This does the actual joining of the lines
 * @param editor    The editor to join the lines in
 * @param startLine The starting logical line
 * @param count     The number of lines to join including startLine
 * @param spaces    If true the joined lines will have one space between them and any leading space on the second linewill be removed. If false, only the newline is removed to join the lines.
 * @return true if able to join the lines, false if not
 */
private boolean deleteJoinNLines(@NotNull Editor editor,int startLine,int count,boolean spaces){
  MotionGroup.moveCaret(editor,VimPlugin.getMotion().moveCaretToLineEnd(editor,startLine,true));
  for (int i=1; i < count; i++) {
    int start=VimPlugin.getMotion().moveCaretToLineEnd(editor);
    int trailingWhitespaceStart=VimPlugin.getMotion().moveCaretToLineEndSkipLeading(editor);
    boolean hasTrailingWhitespace=start != trailingWhitespaceStart + 1;
    MotionGroup.moveCaret(editor,start);
    int offset;
    if (spaces) {
      offset=VimPlugin.getMotion().moveCaretToLineStartSkipLeadingOffset(editor,1);
    }
 else {
      offset=VimPlugin.getMotion().moveCaretToLineStartOffset(editor);
    }
    deleteText(editor,new TextRange(editor.getCaretModel().getOffset(),offset),null);
    if (spaces && !hasTrailingWhitespace) {
      insertText(editor,start,"String_Node_Str");
      MotionGroup.moveCaret(editor,VimPlugin.getMotion().moveCaretHorizontal(editor,-1,false));
    }
  }
  return true;
}
Program: 194
Project: 194
Buggy source:
/** 
 * This performs the actual case change.
 * @param editor  The editor to change
 * @param start   The start offset to change
 * @param end     The end offset to change
 * @param type    The type of change (TOGGLE, UPPER, LOWER)
 */
private void changeCase(@NotNull Editor editor,int start,int end,char type){
  if (start > end) {
    int t=end;
    end=start;
    start=t;
  }
  CharSequence chars=editor.getDocument().getCharsSequence();
  for (int i=start; i < end; i++) {
    if (i >= chars.length()) {
      break;
    }
    char ch=CharacterHelper.changeCase(chars.charAt(i),type);
    if (ch != chars.charAt(i)) {
      replaceText(editor,i,i + 1,Character.toString(ch));
    }
  }
}

Fixed version (ground truth):
/** 
 * This performs the actual case change.
 * @param editor  The editor to change
 * @param start   The start offset to change
 * @param end     The end offset to change
 * @param type    The type of change (TOGGLE, UPPER, LOWER)
 */
private void changeCase(@NotNull Editor editor,int start,int end,char type){
  if (start > end) {
    int t=end;
    end=start;
    start=t;
  }
  end=EditorHelper.normalizeOffset(editor,end);
  CharSequence chars=editor.getDocument().getCharsSequence();
  StringBuilder sb=new StringBuilder();
  for (int i=start; i < end; i++) {
    sb.append(CharacterHelper.changeCase(chars.charAt(i),type));
  }
  replaceText(editor,start,end,sb.toString());
}
Program: 195
Project: 195
Buggy source:
public void clear(){
  myText=null;
  if (!ApplicationManager.getApplication().isUnitTestMode()) {
    ExOutputPanel.getInstance(myEditor).deactivate();
  }
}

Fixed version (ground truth):
public void clear(){
  myText=null;
  if (!ApplicationManager.getApplication().isUnitTestMode()) {
    ExOutputPanel.getInstance(myEditor).deactivate(false);
  }
}
Program: 197
Project: 197
Buggy source:
/** 
 * Handles mouse drags by properly setting up visual mode based on the new selection.
 * @param editor The editor the mouse drag occurred in.
 * @param update True if update, false if not.
 */
private void processLineSelection(@NotNull Editor editor,boolean update){
  if (ExEntryPanel.getInstance().isActive()) {
    ExEntryPanel.getInstance().deactivate();
  }
  ExOutputModel.getInstance(editor).clear();
  if (update) {
    if (CommandState.getInstance(editor).getMode() == CommandState.Mode.VISUAL) {
      updateSelection(editor,editor.getCaretModel().getOffset());
    }
  }
 else {
    if (CommandState.getInstance(editor).getMode() == CommandState.Mode.VISUAL) {
      CommandState.getInstance(editor).popState();
    }
    int start=editor.getSelectionModel().getSelectionStart();
    int end=editor.getSelectionModel().getSelectionEnd();
    editor.getSelectionModel().setSelection(start,Math.max(start,end - 1));
    setVisualMode(editor,CommandState.SubMode.VISUAL_LINE);
    VisualChange range=getVisualOperatorRange(editor,Command.FLAG_MOT_LINEWISE);
    if (range.getLines() > 1) {
      MotionGroup.moveCaret(editor,moveCaretVertical(editor,-1));
    }
  }
}

Fixed version (ground truth):
/** 
 * Handles mouse drags by properly setting up visual mode based on the new selection.
 * @param editor The editor the mouse drag occurred in.
 * @param update True if update, false if not.
 */
private void processLineSelection(@NotNull Editor editor,boolean update){
  if (ExEntryPanel.getInstance().isActive()) {
    ExEntryPanel.getInstance().deactivate(false);
  }
  ExOutputModel.getInstance(editor).clear();
  if (update) {
    if (CommandState.getInstance(editor).getMode() == CommandState.Mode.VISUAL) {
      updateSelection(editor,editor.getCaretModel().getOffset());
    }
  }
 else {
    if (CommandState.getInstance(editor).getMode() == CommandState.Mode.VISUAL) {
      CommandState.getInstance(editor).popState();
    }
    int start=editor.getSelectionModel().getSelectionStart();
    int end=editor.getSelectionModel().getSelectionEnd();
    editor.getSelectionModel().setSelection(start,Math.max(start,end - 1));
    setVisualMode(editor,CommandState.SubMode.VISUAL_LINE);
    VisualChange range=getVisualOperatorRange(editor,Command.FLAG_MOT_LINEWISE);
    if (range.getLines() > 1) {
      MotionGroup.moveCaret(editor,moveCaretVertical(editor,-1));
    }
  }
}
Program: 198
Project: 198
Buggy source:
private void processMouseReleased(@NotNull Editor editor,@NotNull CommandState.SubMode mode,int startOff,int endOff){
  if (ExEntryPanel.getInstance().isActive()) {
    ExEntryPanel.getInstance().deactivate();
  }
  ExOutputModel.getInstance(editor).clear();
  if (CommandState.getInstance(editor).getMode() == CommandState.Mode.VISUAL) {
    CommandState.getInstance(editor).popState();
  }
  int start=editor.getSelectionModel().getSelectionStart();
  int end=editor.getSelectionModel().getSelectionEnd();
  if (mode == CommandState.SubMode.VISUAL_LINE) {
    end--;
    endOff--;
  }
  if (end == startOff || end == endOff) {
    int t=start;
    start=end;
    end=t;
    if (mode == CommandState.SubMode.VISUAL_CHARACTER) {
      start--;
    }
  }
  MotionGroup.moveCaret(editor,start);
  toggleVisual(editor,1,0,mode);
  MotionGroup.moveCaret(editor,end);
  KeyHandler.getInstance().reset(editor);
}

Fixed version (ground truth):
private void processMouseReleased(@NotNull Editor editor,@NotNull CommandState.SubMode mode,int startOff,int endOff){
  if (ExEntryPanel.getInstance().isActive()) {
    ExEntryPanel.getInstance().deactivate(false);
  }
  ExOutputModel.getInstance(editor).clear();
  if (CommandState.getInstance(editor).getMode() == CommandState.Mode.VISUAL) {
    CommandState.getInstance(editor).popState();
  }
  int start=editor.getSelectionModel().getSelectionStart();
  int end=editor.getSelectionModel().getSelectionEnd();
  if (mode == CommandState.SubMode.VISUAL_LINE) {
    end--;
    endOff--;
  }
  if (end == startOff || end == endOff) {
    int t=start;
    start=end;
    end=t;
    if (mode == CommandState.SubMode.VISUAL_CHARACTER) {
      start--;
    }
  }
  MotionGroup.moveCaret(editor,start);
  toggleVisual(editor,1,0,mode);
  MotionGroup.moveCaret(editor,end);
  KeyHandler.getInstance().reset(editor);
}
Program: 200
Project: 200
Buggy source:
public String endSearchCommand(@NotNull final Editor editor,@NotNull DataContext context){
  ExEntryPanel panel=ExEntryPanel.getInstance();
  panel.deactivate();
  final Project project=PlatformDataKeys.PROJECT.getData(context);
  SwingUtilities.invokeLater(new Runnable(){
    public void run(){
      VirtualFile vf=EditorData.getVirtualFile(editor);
      if (!ApplicationManager.getApplication().isUnitTestMode() && project != null && vf != null) {
        FileEditorManager.getInstance(project).openFile(vf,true);
      }
    }
  }
);
  record(editor,panel.getText());
  return panel.getText();
}

Fixed version (ground truth):
public String endSearchCommand(@NotNull final Editor editor,@NotNull DataContext context){
  ExEntryPanel panel=ExEntryPanel.getInstance();
  panel.deactivate(true);
  record(editor,panel.getText());
  return panel.getText();
}
Program: 201
Project: 201
Buggy source:
public boolean cancelExEntry(@NotNull final Editor editor,@NotNull final DataContext context){
  CommandState.getInstance(editor).popState();
  KeyHandler.getInstance().reset(editor);
  ExEntryPanel panel=ExEntryPanel.getInstance();
  panel.deactivate();
  final Project project=PlatformDataKeys.PROJECT.getData(context);
  SwingUtilities.invokeLater(new Runnable(){
    public void run(){
      VirtualFile vf=EditorData.getVirtualFile(editor);
      if (project != null && vf != null) {
        FileEditorManager.getInstance(project).openFile(vf,true);
      }
    }
  }
);
  return true;
}

Fixed version (ground truth):
public boolean cancelExEntry(@NotNull final Editor editor,@NotNull final DataContext context){
  CommandState.getInstance(editor).popState();
  KeyHandler.getInstance().reset(editor);
  ExEntryPanel panel=ExEntryPanel.getInstance();
  panel.deactivate(true);
  return true;
}
Program: 202
Project: 202
Buggy source:
/** 
 * Turns off the ex entry field and puts the focus back to the original component
 */
public void deactivate(){
  logger.info("String_Node_Str");
  if (!active)   return;
  active=false;
  if (!ApplicationManager.getApplication().isUnitTestMode()) {
    oldGlass.removeComponentListener(adapter);
    oldGlass.setVisible(false);
    oldGlass.remove(this);
    oldGlass.setOpaque(wasOpaque);
    oldGlass.setLayout(oldLayout);
  }
  parent=null;
}

Fixed version (ground truth):
/** 
 * Turns off the ex entry field and optionally puts the focus back to the original component
 */
public void deactivate(boolean refocusOwningEditor){
  logger.info("String_Node_Str");
  if (!active)   return;
  active=false;
  if (!ApplicationManager.getApplication().isUnitTestMode()) {
    if (refocusOwningEditor) {
      parent.requestFocus();
    }
    oldGlass.removeComponentListener(adapter);
    oldGlass.setVisible(false);
    oldGlass.remove(this);
    oldGlass.setOpaque(wasOpaque);
    oldGlass.setLayout(oldLayout);
  }
  parent=null;
}
Program: 203
Project: 203
Buggy source:
public void run(){
  deactivate();
  final VirtualFile vf=EditorData.getVirtualFile(myEditor);
  if (vf != null) {
    FileEditorManager.getInstance(myEditor.getProject()).openFile(vf,true);
  }
  final Project project=myEditor.getProject();
  if (project != null && e != null && e.getKeyChar() != '\n') {
    final KeyStroke key=KeyStroke.getKeyStrokeForEvent(e);
    final List<KeyStroke> keys=new ArrayList<KeyStroke>(1);
    keys.add(key);
    VimPlugin.getMacro().playbackKeys(myEditor,new EditorDataContext(myEditor),project,keys,0,0,1);
  }
}

Fixed version (ground truth):
public void run(){
  deactivate(true);
  final Project project=myEditor.getProject();
  if (project != null && e != null && e.getKeyChar() != '\n') {
    final KeyStroke key=KeyStroke.getKeyStrokeForEvent(e);
    final List<KeyStroke> keys=new ArrayList<KeyStroke>(1);
    keys.add(key);
    VimPlugin.getMacro().playbackKeys(myEditor,new EditorDataContext(myEditor),project,keys,0,0,1);
  }
}
Program: 204
Project: 204
Buggy source:
/** 
 * Turns off the ex entry field and puts the focus back to the original component
 */
public void deactivate(){
  if (!myActive)   return;
  myActive=false;
  myText.setText("String_Node_Str");
  if (myOldGlass != null) {
    myOldGlass.removeComponentListener(myAdapter);
    myOldGlass.setVisible(false);
    myOldGlass.remove(this);
    myOldGlass.setOpaque(myWasOpaque);
    myOldGlass.setLayout(myOldLayout);
  }
  myEditor.getContentComponent().requestFocus();
}

Fixed version (ground truth):
/** 
 * Turns off the ex entry field and optionally puts the focus back to the original component
 */
public void deactivate(boolean refocusOwningEditor){
  if (!myActive)   return;
  myActive=false;
  myText.setText("String_Node_Str");
  if (refocusOwningEditor) {
    myEditor.getContentComponent().requestFocus();
  }
  if (myOldGlass != null) {
    myOldGlass.removeComponentListener(myAdapter);
    myOldGlass.setVisible(false);
    myOldGlass.remove(this);
    myOldGlass.setOpaque(myWasOpaque);
    myOldGlass.setLayout(myOldLayout);
  }
}
Program: 205
Project: 205
Buggy source:
/** 
 * Turns on the more window for the given editor
 */
private void activate(){
  JRootPane root=SwingUtilities.getRootPane(myEditor.getContentComponent());
  myOldGlass=(JComponent)root.getGlassPane();
  if (myOldGlass != null) {
    myOldLayout=myOldGlass.getLayout();
    myWasOpaque=myOldGlass.isOpaque();
    myOldGlass.setLayout(null);
    myOldGlass.setOpaque(false);
    myOldGlass.add(this);
    myOldGlass.addComponentListener(myAdapter);
  }
  setFontForElements();
  positionPanel();
  if (myOldGlass != null) {
    myOldGlass.setVisible(true);
  }
  myActive=true;
  SwingUtilities.invokeLater(new Runnable(){
    public void run(){
      SwingUtilities.invokeLater(new Runnable(){
        public void run(){
          myText.requestFocus();
        }
      }
);
    }
  }
);
}

Fixed version (ground truth):
/** 
 * Turns on the more window for the given editor
 */
private void activate(){
  JRootPane root=SwingUtilities.getRootPane(myEditor.getContentComponent());
  myOldGlass=(JComponent)root.getGlassPane();
  if (myOldGlass != null) {
    myOldLayout=myOldGlass.getLayout();
    myWasOpaque=myOldGlass.isOpaque();
    myOldGlass.setLayout(null);
    myOldGlass.setOpaque(false);
    myOldGlass.add(this);
    myOldGlass.addComponentListener(myAdapter);
  }
  setFontForElements();
  positionPanel();
  if (myOldGlass != null) {
    myOldGlass.setVisible(true);
  }
  myActive=true;
  myText.requestFocus();
}
Program: 206
Project: 206
Buggy source:
private void close(@Nullable final KeyEvent e){
  SwingUtilities.invokeLater(new Runnable(){
    public void run(){
      deactivate();
      final VirtualFile vf=EditorData.getVirtualFile(myEditor);
      if (vf != null) {
        FileEditorManager.getInstance(myEditor.getProject()).openFile(vf,true);
      }
      final Project project=myEditor.getProject();
      if (project != null && e != null && e.getKeyChar() != '\n') {
        final KeyStroke key=KeyStroke.getKeyStrokeForEvent(e);
        final List<KeyStroke> keys=new ArrayList<KeyStroke>(1);
        keys.add(key);
        VimPlugin.getMacro().playbackKeys(myEditor,new EditorDataContext(myEditor),project,keys,0,0,1);
      }
    }
  }
);
}

Fixed version (ground truth):
private void close(@Nullable final KeyEvent e){
  SwingUtilities.invokeLater(new Runnable(){
    public void run(){
      deactivate(true);
      final Project project=myEditor.getProject();
      if (project != null && e != null && e.getKeyChar() != '\n') {
        final KeyStroke key=KeyStroke.getKeyStrokeForEvent(e);
        final List<KeyStroke> keys=new ArrayList<KeyStroke>(1);
        keys.add(key);
        VimPlugin.getMacro().playbackKeys(myEditor,new EditorDataContext(myEditor),project,keys,0,0,1);
      }
    }
  }
);
}
Program: 207
Project: 207
Buggy source:
public void setText(@NotNull String data){
  if (data.length() > 0 && data.charAt(data.length() - 1) == '\n') {
    data=data.substring(0,data.length() - 1);
  }
  myText.setText(data);
  myText.setCaretPosition(0);
  if (data.length() > 0) {
    SwingUtilities.invokeLater(new Runnable(){
      @Override public void run(){
        activate();
      }
    }
);
  }
}

Fixed version (ground truth):
public void setText(@NotNull String data){
  if (data.length() > 0 && data.charAt(data.length() - 1) == '\n') {
    data=data.substring(0,data.length() - 1);
  }
  myText.setText(data);
  myText.setCaretPosition(0);
  if (data.length() > 0) {
    activate();
  }
}
Program: 208
Project: 208
Buggy source:
@Override protected void tearDown() throws Exception {
  myFixture.tearDown();
  myFixture=null;
  ExEntryPanel.getInstance().deactivate();
  super.tearDown();
}

Fixed version (ground truth):
@Override protected void tearDown() throws Exception {
  myFixture.tearDown();
  myFixture=null;
  ExEntryPanel.getInstance().deactivate(false);
  super.tearDown();
}
Program: 210
Project: 210
Buggy source:
/** 
 * @return true if keymap was installed or was successfully installed
 */
public static boolean installKeyBoardBindings(){
  LOG.debug("String_Node_Str");
  final LocalFileSystem localFileSystem=LocalFileSystem.getInstance();
  if (localFileSystem.refreshAndFindFileByPath(KEYMAPS_PATH) == null) {
    reportError("String_Node_Str");
    return false;
  }
  LOG.debug("String_Node_Str");
  try {
    final byte[] bytes=toByteArray(retrieveSourceKeymapStream());
    Files.write(bytes,new File(INSTALLED_VIM_KEYMAP_PATH));
    final Document document=StorageUtil.loadDocument(bytes);
    if (document != null && !ApplicationManager.getApplication().isUnitTestMode()) {
      configureVimParentKeymap(INSTALLED_VIM_KEYMAP_PATH,document,true);
    }
    installKeymap(document);
  }
 catch (  IOException e) {
    reportError("String_Node_Str",e);
    return false;
  }
catch (  InvalidDataException e) {
    reportError("String_Node_Str",e);
    return false;
  }
catch (  Exception e) {
    reportError("String_Node_Str",e);
    return false;
  }
  return true;
}

Fixed version (ground truth):
/** 
 * @return true if keymap was installed or was successfully installed
 */
public static boolean installKeyBoardBindings(){
  LOG.debug("String_Node_Str");
  final LocalFileSystem localFileSystem=LocalFileSystem.getInstance();
  if (localFileSystem.refreshAndFindFileByPath(KEYMAPS_PATH) == null) {
    reportError("String_Node_Str");
    return false;
  }
  LOG.debug("String_Node_Str");
  try {
    final byte[] bytes=toByteArray(retrieveSourceKeymapStream());
    Files.write(bytes,new File(INSTALLED_VIM_KEYMAP_PATH));
    final Document document=StorageUtil.loadDocument(bytes);
    if (document != null && !ApplicationManager.getApplication().isUnitTestMode()) {
      if (!configureVimParentKeymap(INSTALLED_VIM_KEYMAP_PATH,document,true)) {
        return false;
      }
    }
    installKeymap(document);
  }
 catch (  IOException e) {
    reportError("String_Node_Str",e);
    return false;
  }
catch (  InvalidDataException e) {
    reportError("String_Node_Str",e);
    return false;
  }
catch (  Exception e) {
    reportError("String_Node_Str",e);
    return false;
  }
  return true;
}
Program: 211
Project: 211
Buggy source:
private static Element createActionElement(String actionName,List<Shortcut> shortcuts){
  final Element overridesAction=new Element(ACTION_TAG);
  overridesAction.setAttribute(ID_ATTRIBUTE,actionName);
  for (  Shortcut shortcut : shortcuts) {
    if (shortcut instanceof KeyboardShortcut) {
      KeyboardShortcut keyboardShortcut=(KeyboardShortcut)shortcut;
      overridesAction.addContent(createShortcutElement(KEYBOARD_SHORTCUT_TAG,FIRST_KEYSTROKE_ATTRIBUTE,KeymapImpl.getKeyShortcutString(keyboardShortcut.getFirstKeyStroke())));
    }
 else     if (shortcut instanceof MouseShortcut) {
      overridesAction.addContent(createShortcutElement(MOUSE_SHORTCUT_TAG,KEYSTROKE_ATTRIBUTE,getMouseShortcutString((MouseShortcut)shortcut)));
    }
  }
  return overridesAction;
}

Fixed version (ground truth):
public static Element createActionElement(String actionName,List<Shortcut> shortcuts){
  final Element overridesAction=new Element(ACTION_TAG);
  overridesAction.setAttribute(ID_ATTRIBUTE,actionName);
  for (  Shortcut shortcut : shortcuts) {
    if (shortcut instanceof KeyboardShortcut) {
      KeyboardShortcut keyboardShortcut=(KeyboardShortcut)shortcut;
      overridesAction.addContent(createShortcutElement(KEYBOARD_SHORTCUT_TAG,FIRST_KEYSTROKE_ATTRIBUTE,KeymapImpl.getKeyShortcutString(keyboardShortcut.getFirstKeyStroke())));
    }
 else     if (shortcut instanceof MouseShortcut) {
      overridesAction.addContent(createShortcutElement(MOUSE_SHORTCUT_TAG,KEYSTROKE_ATTRIBUTE,getMouseShortcutString((MouseShortcut)shortcut)));
    }
  }
  return overridesAction;
}
Program: 212
Project: 212
Buggy source:
/** 
 * Begin insert at the location of the previous insert
 * @param editor  The editor to insert into
 * @param context The data context
 */
public void insertAtPreviousInsert(Editor editor,DataContext context){
  int offset=CommandGroups.getInstance().getMotion().moveCaretToFileMarkLine(editor,'^');
  if (offset != -1) {
    MotionGroup.moveCaret(editor,offset);
  }
  insertBeforeCursor(editor,context);
}

Fixed version (ground truth):
/** 
 * Begin insert at the location of the previous insert
 * @param editor  The editor to insert into
 * @param context The data context
 */
public void insertAtPreviousInsert(Editor editor,DataContext context){
  int offset=CommandGroups.getInstance().getMotion().moveCaretToMark(editor,context,'^');
  if (offset != -1) {
    MotionGroup.moveCaret(editor,offset);
  }
  insertAfterCursor(editor,context);
}
Program: 213
Project: 213
Buggy source:
@Override protected void setUp() throws Exception {
  super.setUp();
  final IdeaTestFixtureFactory factory=IdeaTestFixtureFactory.getFixtureFactory();
  final LightProjectDescriptor projectDescriptor=LightProjectDescriptor.EMPTY_PROJECT_DESCRIPTOR;
  final TestFixtureBuilder<IdeaProjectTestFixture> fixtureBuilder=factory.createLightFixtureBuilder(projectDescriptor);
  final IdeaProjectTestFixture fixture=fixtureBuilder.getFixture();
  myFixture=IdeaTestFixtureFactory.getFixtureFactory().createCodeInsightFixture(fixture,new LightTempDirTestFixtureImpl(true));
  myFixture.setUp();
  myFixture.setTestDataPath(getTestDataPath());
}

Fixed version (ground truth):
@Override protected void setUp() throws Exception {
  super.setUp();
  final IdeaTestFixtureFactory factory=IdeaTestFixtureFactory.getFixtureFactory();
  final LightProjectDescriptor projectDescriptor=LightProjectDescriptor.EMPTY_PROJECT_DESCRIPTOR;
  final TestFixtureBuilder<IdeaProjectTestFixture> fixtureBuilder=factory.createLightFixtureBuilder(projectDescriptor);
  final IdeaProjectTestFixture fixture=fixtureBuilder.getFixture();
  myFixture=IdeaTestFixtureFactory.getFixtureFactory().createCodeInsightFixture(fixture,new LightTempDirTestFixtureImpl(true));
  myFixture.setUp();
  myFixture.setTestDataPath(getTestDataPath());
  Options.getInstance().resetAllOptions();
}
Program: 214
Project: 214
Buggy source:
public void testEOLWithHighlightSearch(){
  final Options options=Options.getInstance();
  options.resetAllOptions();
  final Option option=options.getOption("String_Node_Str");
  assertInstanceOf(option,ToggleOption.class);
  final ToggleOption highlightSearch=(ToggleOption)option;
  highlightSearch.set();
  final int pos=search("String_Node_Str","String_Node_Str" + "String_Node_Str");
  assertEquals(3,pos);
}

Fixed version (ground truth):
public void testEOLWithHighlightSearch(){
  setHighlightSearch();
  final int pos=search("String_Node_Str","String_Node_Str" + "String_Node_Str");
  assertEquals(3,pos);
}
Program: 215
Project: 215
Buggy source:
public void testEOL(){
  Options.getInstance().resetAllOptions();
  final int pos=search("String_Node_Str","String_Node_Str" + "String_Node_Str");
  assertEquals(3,pos);
}

Fixed version (ground truth):
public void testEOL(){
  final int pos=search("String_Node_Str","String_Node_Str" + "String_Node_Str");
  assertEquals(3,pos);
}
Program: 216
Project: 216
Buggy source:
public static int normalizeOffset(final Editor editor,int offset,final boolean allowEnd){
  if (offset <= 0) {
    return 0;
  }
  final int textLength=editor.getDocument().getTextLength();
  if (offset > textLength) {
    offset=textLength;
  }
  if (offset > 0 && !allowEnd && editor.getDocument().getCharsSequence().charAt(textLength - 1) == '\n') {
    offset--;
  }
  return offset;
}

Fixed version (ground truth):
public static int normalizeOffset(final Editor editor,int offset,final boolean allowEnd){
  if (offset <= 0) {
    offset=0;
  }
  final int textLength=editor.getDocument().getTextLength();
  if (offset > textLength) {
    offset=textLength;
  }
  final int line=editor.offsetToLogicalPosition(offset).line;
  return normalizeOffset(editor,line,offset,allowEnd);
}
Program: 217
Project: 217
Buggy source:
/** 
 * Begin insert at the location of the previous insert
 * @param editor  The editor to insert into
 * @param context The data context
 */
public void insertAtPreviousInsert(Editor editor,DataContext context){
  int offset=CommandGroups.getInstance().getMotion().moveCaretToFileMarkLine(editor,'^');
  if (offset != -1) {
    MotionGroup.moveCaret(editor,context,offset);
  }
  insertBeforeCursor(editor,context);
}

Fixed version (ground truth):
/** 
 * Begin insert at the location of the previous insert
 * @param editor  The editor to insert into
 * @param context The data context
 */
public void insertAtPreviousInsert(Editor editor,DataContext context){
  int offset=CommandGroups.getInstance().getMotion().moveCaretToMark(editor,context,'^');
  if (offset != -1) {
    MotionGroup.moveCaret(editor,context,offset);
  }
  insertAfterCursor(editor,context);
}
Program: 219
Project: 219
Buggy source:
public void editorCreated(EditorFactoryEvent event){
  final Editor editor=event.getEditor();
  isBlockCursor=editor.getSettings().isBlockCursor();
  isSmoothScrolling=editor.getSettings().isAnimatedScrolling();
  EditorData.initializeEditor(editor);
  DocumentManager.getInstance().addListeners(editor.getDocument());
  if (VimPlugin.isEnabled()) {
    final VirtualFile virtualFile=EditorData.getVirtualFile(editor);
    if (virtualFile == null || virtualFile instanceof LightVirtualFile) {
      CommandGroups.getInstance().getChange().insertBeforeCursor(editor,new EditorDataContext(editor));
    }
    editor.getSettings().setBlockCursor(!CommandState.inInsertMode(editor));
    editor.getSettings().setAnimatedScrolling(false);
  }
}

Fixed version (ground truth):
public void editorCreated(EditorFactoryEvent event){
  final Editor editor=event.getEditor();
  isBlockCursor=editor.getSettings().isBlockCursor();
  isSmoothScrolling=editor.getSettings().isAnimatedScrolling();
  EditorData.initializeEditor(editor);
  DocumentManager.getInstance().addListeners(editor.getDocument());
  if (VimPlugin.isEnabled()) {
    if (!EditorData.isFileEditor(editor)) {
      CommandGroups.getInstance().getChange().insertBeforeCursor(editor,new EditorDataContext(editor));
    }
    editor.getSettings().setBlockCursor(!CommandState.inInsertMode(editor));
    editor.getSettings().setAnimatedScrolling(false);
  }
}
Program: 220
Project: 220
Buggy source:
@Override public void propertyChange(PropertyChangeEvent evt){
  if (LookupManager.PROP_ACTIVE_LOOKUP.equals(evt.getPropertyName())) {
    final Lookup lookup=(Lookup)evt.getNewValue();
    if (lookup != null) {
      final Editor editor=lookup.getEditor();
      CommandGroups.getInstance().getChange().insertBeforeCursor(editor,new EditorDataContext(editor));
    }
  }
}

Fixed version (ground truth):
@Override public void propertyChange(PropertyChangeEvent evt){
  if (LookupManager.PROP_ACTIVE_LOOKUP.equals(evt.getPropertyName())) {
    final Lookup lookup=(Lookup)evt.getNewValue();
    if (lookup != null && lookup.isFocused()) {
      final Editor editor=lookup.getEditor();
      if (!CommandState.inInsertMode(editor)) {
        CommandGroups.getInstance().getChange().insertBeforeCursor(editor,new EditorDataContext(editor));
      }
    }
  }
}
Program: 221
Project: 221
Buggy source:
public void projectOpened(Project project){
  listeners.add(new MotionGroup.MotionEditorChange());
  listeners.add(new FileGroup.SelectionCheck());
  listeners.add(new SearchGroup.EditorSelectionCheck());
  for (  FileEditorManagerListener listener : listeners) {
    FileEditorManager.getInstance(project).addFileEditorManagerListener(listener);
  }
  myLookupPropertiesListener=new PropertyChangeListener(){
    @Override public void propertyChange(    PropertyChangeEvent evt){
      if (LookupManager.PROP_ACTIVE_LOOKUP.equals(evt.getPropertyName())) {
        final Lookup lookup=(Lookup)evt.getNewValue();
        if (lookup != null) {
          final Editor editor=lookup.getEditor();
          CommandGroups.getInstance().getChange().insertBeforeCursor(editor,new EditorDataContext(editor));
        }
      }
    }
  }
;
  LookupManager.getInstance(project).addPropertyChangeListener(myLookupPropertiesListener);
}

Fixed version (ground truth):
public void projectOpened(Project project){
  listeners.add(new MotionGroup.MotionEditorChange());
  listeners.add(new FileGroup.SelectionCheck());
  listeners.add(new SearchGroup.EditorSelectionCheck());
  for (  FileEditorManagerListener listener : listeners) {
    FileEditorManager.getInstance(project).addFileEditorManagerListener(listener);
  }
  myLookupPropertiesListener=new PropertyChangeListener(){
    @Override public void propertyChange(    PropertyChangeEvent evt){
      if (LookupManager.PROP_ACTIVE_LOOKUP.equals(evt.getPropertyName())) {
        final Lookup lookup=(Lookup)evt.getNewValue();
        if (lookup != null && lookup.isFocused()) {
          final Editor editor=lookup.getEditor();
          if (!CommandState.inInsertMode(editor)) {
            CommandGroups.getInstance().getChange().insertBeforeCursor(editor,new EditorDataContext(editor));
          }
        }
      }
    }
  }
;
  LookupManager.getInstance(project).addPropertyChangeListener(myLookupPropertiesListener);
}
Program: 222
Project: 222
Buggy source:
/** 
 * Terminate insert/replace mode after the user presses Escape or Ctrl-C
 * @param editor  The editor that was being edited
 * @param context The data context
 */
public void processEscape(Editor editor,DataContext context){
  logger.debug("String_Node_Str");
  if (lastInsert == null) {
    return;
  }
  int cnt=lastInsert.getCount();
  if (CommandState.getInstance(editor).getMode() == CommandState.MODE_REPLACE) {
    KeyHandler.executeAction("String_Node_Str",context);
  }
  if ((lastInsert.getFlags() & Command.FLAG_NO_REPEAT) != 0) {
    cnt=1;
  }
  lastStrokes=new ArrayList(strokes);
  repeatInsert(editor,context,cnt - 1,true);
  CommandGroups.getInstance().getMark().setMark(editor,context,'^',editor.getCaretModel().getOffset());
  CommandGroups.getInstance().getMark().setMark(editor,context,']',editor.getCaretModel().getOffset());
  CommandState.getInstance(editor).popState();
  if (!CommandState.inInsertMode(editor)) {
    resetCursor(editor,false);
  }
}

Fixed version (ground truth):
/** 
 * Terminate insert/replace mode after the user presses Escape or Ctrl-C
 * @param editor  The editor that was being edited
 * @param context The data context
 */
public void processEscape(Editor editor,DataContext context){
  logger.debug("String_Node_Str");
  int cnt=lastInsert != null ? lastInsert.getCount() : 0;
  if (CommandState.getInstance(editor).getMode() == CommandState.MODE_REPLACE) {
    KeyHandler.executeAction("String_Node_Str",context);
  }
  if ((lastInsert.getFlags() & Command.FLAG_NO_REPEAT) != 0) {
    cnt=1;
  }
  lastStrokes=new ArrayList(strokes);
  repeatInsert(editor,context,cnt == 0 ? 0 : cnt - 1,true);
  CommandGroups.getInstance().getMark().setMark(editor,context,'^',editor.getCaretModel().getOffset());
  CommandGroups.getInstance().getMark().setMark(editor,context,']',editor.getCaretModel().getOffset());
  CommandState.getInstance(editor).popState();
  if (!CommandState.inInsertMode(editor)) {
    resetCursor(editor,false);
  }
}
Program: 224
Project: 224
Buggy source:
public static void reconfigureParentKeymap(){
  final VirtualFile vimKeymapFile=getVimKeymapFile();
  if (vimKeymapFile == null) {
    Notifications.Bus.notify(new Notification("String_Node_Str","String_Node_Str","String_Node_Str",NotificationType.ERROR));
    return;
  }
  try {
    final String path=vimKeymapFile.getPath();
    final Document document=StorageUtil.loadDocument(new FileInputStream(path));
    if (document == null) {
      LOG.debug("String_Node_Str");
      Notifications.Bus.notify(new Notification("String_Node_Str","String_Node_Str","String_Node_Str",NotificationType.ERROR));
      return;
    }
    configureVimParentKeymap(path,document);
  }
 catch (  Exception e) {
    LOG.debug("String_Node_Str" + e);
    Notifications.Bus.notify(new Notification("String_Node_Str","String_Node_Str","String_Node_Str" + e,NotificationType.ERROR));
  }
}

Fixed version (ground truth):
public static void reconfigureParentKeymap(){
  final VirtualFile vimKeymapFile=getVimKeymapFile();
  if (vimKeymapFile == null) {
    Notifications.Bus.notify(new Notification("String_Node_Str","String_Node_Str","String_Node_Str",NotificationType.ERROR));
    return;
  }
  try {
    final String path=vimKeymapFile.getPath();
    final Document document=StorageUtil.loadDocument(new FileInputStream(path));
    if (document == null) {
      LOG.debug("String_Node_Str");
      Notifications.Bus.notify(new Notification("String_Node_Str","String_Node_Str","String_Node_Str",NotificationType.ERROR));
      return;
    }
    configureVimParentKeymap(path,document);
  }
 catch (  Exception e) {
    LOG.error("String_Node_Str" + e);
    Notifications.Bus.notify(new Notification("String_Node_Str","String_Node_Str","String_Node_Str" + e,NotificationType.ERROR));
  }
}
Program: 226
Project: 226
Buggy source:
public void mouseDragged(EditorMouseEvent event){
  if (!VimPlugin.isEnabled())   return;
  if (event.getArea() == EditorMouseEventArea.EDITING_AREA) {
    dragEditor=event.getEditor();
  }
}

Fixed version (ground truth):
public void mouseDragged(EditorMouseEvent event){
  if (!VimPlugin.isEnabled())   return;
  if (event.getArea() == EditorMouseEventArea.EDITING_AREA || event.getArea() == EditorMouseEventArea.LINE_NUMBERS_AREA) {
    dragEditor=event.getEditor();
  }
}
Program: 227
Project: 227
Buggy source:
public boolean swapVisualSelections(Editor editor,DataContext context){
  VisualRange vr=EditorData.getLastVisualRange(editor);
  if (vr == null) {
    return false;
  }
  EditorData.setLastVisualRange(editor,new VisualRange(visualStart,visualEnd,CommandState.getInstance().getSubMode()));
  visualStart=vr.getStart();
  visualEnd=vr.getEnd();
  CommandState.getInstance().setSubMode(vr.getType());
  updateSelection(editor,context,vr.getEnd());
  MotionGroup.moveCaret(editor,context,visualEnd);
  return true;
}

Fixed version (ground truth):
public boolean swapVisualSelections(Editor editor,DataContext context){
  VisualRange vr=EditorData.getLastVisualRange(editor);
  if (vr == null) {
    return false;
  }
  EditorData.setLastVisualRange(editor,new VisualRange(visualStart,visualEnd,CommandState.getInstance().getSubMode(),visualOffset));
  visualStart=vr.getStart();
  visualEnd=vr.getEnd();
  visualOffset=vr.getOffset();
  CommandState.getInstance().setSubMode(vr.getType());
  updateSelection(editor,context,visualEnd);
  editor.getCaretModel().moveToOffset(visualOffset);
  editor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE);
  return true;
}
Program: 229
Project: 229
Buggy source:
public void resetVisual(Editor editor){
  logger.debug("String_Node_Str");
  EditorData.setLastVisualRange(editor,new VisualRange(visualStart,visualEnd,CommandState.getInstance().getSubMode()));
  editor.getSelectionModel().removeSelection();
  CommandState.getInstance().setSubMode(0);
}

Fixed version (ground truth):
public void resetVisual(Editor editor){
  logger.debug("String_Node_Str");
  EditorData.setLastVisualRange(editor,new VisualRange(visualStart,visualEnd,CommandState.getInstance().getSubMode(),visualOffset));
  logger.debug("String_Node_Str" + visualStart + "String_Node_Str"+ visualEnd);
  editor.getSelectionModel().removeSelection();
  CommandState.getInstance().setSubMode(0);
}
Program: 230
Project: 230
Buggy source:
public void mouseClicked(EditorMouseEvent event){
  if (!VimPlugin.isEnabled())   return;
  if (event.getArea() == EditorMouseEventArea.EDITING_AREA) {
    CommandGroups.getInstance().getMotion().processMouseClick(event.getEditor(),event.getMouseEvent());
    event.consume();
  }
}

Fixed version (ground truth):
public void mouseClicked(EditorMouseEvent event){
  if (!VimPlugin.isEnabled())   return;
  if (event.getArea() == EditorMouseEventArea.EDITING_AREA) {
    CommandGroups.getInstance().getMotion().processMouseClick(event.getEditor(),event.getMouseEvent());
    event.consume();
  }
 else   if (event.getArea() == EditorMouseEventArea.LINE_NUMBERS_AREA) {
    CommandGroups.getInstance().getMotion().processLineSelection(event.getEditor(),event.getMouseEvent().getButton() == MouseEvent.BUTTON3);
    event.consume();
  }
}
Program: 231
Project: 231
Buggy source:
/** 
 * Handles mouse drags by properly setting up visual mode based on the new selection
 * @param editor The editor the mouse drag occured in
 */
private void processMouseDrag(Editor editor){
  setVisualMode(editor,null,Command.FLAG_MOT_CHARACTERWISE);
  int offset=editor.getCaretModel().getOffset();
  int start=editor.getSelectionModel().getSelectionStart();
  if (offset > start) {
    BoundStringOption opt=(BoundStringOption)Options.getInstance().getOption("String_Node_Str");
    if (!opt.getValue().equals("String_Node_Str")) {
      editor.getCaretModel().moveToOffset(offset - 1);
    }
  }
  EditorData.setLastColumn(editor,EditorHelper.getCurrentVisualColumn(editor));
}

Fixed version (ground truth):
/** 
 * Handles mouse drags by properly setting up visual mode based on the new selection
 * @param editor The editor the mouse drag occured in
 */
private void processMouseDrag(Editor editor){
  if (CommandState.getInstance().getMode() == CommandState.MODE_VISUAL) {
    CommandState.getInstance().popState();
  }
  int offset=editor.getCaretModel().getOffset();
  int start=editor.getSelectionModel().getSelectionStart();
  logger.debug("String_Node_Str" + offset + "String_Node_Str"+ start);
  if (offset > start) {
    BoundStringOption opt=(BoundStringOption)Options.getInstance().getOption("String_Node_Str");
    if (!opt.getValue().equals("String_Node_Str")) {
      logger.debug("String_Node_Str");
      editor.getCaretModel().moveToOffset(offset - 1);
    }
  }
  setVisualMode(editor,null,Command.FLAG_MOT_CHARACTERWISE);
  EditorData.setLastColumn(editor,EditorHelper.getCurrentVisualColumn(editor));
}
Program: 233
Project: 233
Buggy source:
private void updateSelection(Editor editor,DataContext context,int offset){
  visualEnd=offset;
  int start=visualStart;
  int end=visualEnd;
  if (start > end) {
    int t=start;
    start=end;
    end=t;
  }
  if (CommandState.getInstance().getSubMode() == Command.FLAG_MOT_CHARACTERWISE) {
    BoundStringOption opt=(BoundStringOption)Options.getInstance().getOption("String_Node_Str");
    int adj=1;
    if (opt.getValue().equals("String_Node_Str")) {
      adj=0;
    }
    end=Math.min(EditorHelper.getFileSize(editor),end + adj);
    editor.getSelectionModel().setSelection(start,end);
  }
 else {
    start=EditorHelper.getLineStartForOffset(editor,start);
    end=EditorHelper.getLineEndForOffset(editor,end);
    editor.getSelectionModel().setSelection(start,end);
  }
  CommandGroups.getInstance().getMark().setMark(editor,context,'<',start);
  CommandGroups.getInstance().getMark().setMark(editor,context,'>',end);
}

Fixed version (ground truth):
private void updateSelection(Editor editor,DataContext context,int offset){
  logger.debug("String_Node_Str");
  visualEnd=offset;
  visualOffset=offset;
  int start=visualStart;
  int end=visualEnd;
  if (start > end) {
    int t=start;
    start=end;
    end=t;
  }
  if (CommandState.getInstance().getSubMode() == Command.FLAG_MOT_CHARACTERWISE) {
    BoundStringOption opt=(BoundStringOption)Options.getInstance().getOption("String_Node_Str");
    int adj=1;
    if (opt.getValue().equals("String_Node_Str")) {
      adj=0;
    }
    end=Math.min(EditorHelper.getFileSize(editor),end + adj);
    logger.debug("String_Node_Str" + start + "String_Node_Str"+ end);
    editor.getSelectionModel().setSelection(start,end);
  }
 else {
    start=EditorHelper.getLineStartForOffset(editor,start);
    end=EditorHelper.getLineEndForOffset(editor,end);
    logger.debug("String_Node_Str" + start + "String_Node_Str"+ end);
    editor.getSelectionModel().setSelection(start,end);
  }
  CommandGroups.getInstance().getMark().setMark(editor,context,'<',start);
  CommandGroups.getInstance().getMark().setMark(editor,context,'>',end);
}
Program: 234
Project: 234
Buggy source:
public void mouseReleased(EditorMouseEvent event){
  if (!VimPlugin.isEnabled())   return;
  if (event.getArea() == EditorMouseEventArea.EDITING_AREA) {
    if (event.getEditor().equals(dragEditor)) {
      CommandGroups.getInstance().getMotion().processMouseDrag(event.getEditor());
      event.consume();
    }
    dragEditor=null;
  }
}

Fixed version (ground truth):
public void mouseReleased(EditorMouseEvent event){
  if (!VimPlugin.isEnabled())   return;
  if (event.getEditor().equals(dragEditor)) {
    if (event.getArea() == EditorMouseEventArea.EDITING_AREA) {
      CommandGroups.getInstance().getMotion().processMouseDrag(event.getEditor());
    }
 else     if (event.getArea() == EditorMouseEventArea.LINE_NUMBERS_AREA) {
      CommandGroups.getInstance().getMotion().processLineSelection(event.getEditor(),false);
    }
    event.consume();
    dragEditor=null;
  }
}
Program: 235
Project: 235
Buggy source:
public boolean selectPreviousVisualMode(Editor editor,DataContext context){
  VisualRange vr=EditorData.getLastVisualRange(editor);
  if (vr == null) {
    return false;
  }
  CommandState.getInstance().pushState(CommandState.MODE_VISUAL,vr.getType(),KeyParser.MAPPING_VISUAL);
  visualStart=vr.getStart();
  visualEnd=vr.getEnd();
  updateSelection(editor,context,visualEnd);
  MotionGroup.moveCaret(editor,context,visualEnd);
  return true;
}

Fixed version (ground truth):
public boolean selectPreviousVisualMode(Editor editor,DataContext context){
  logger.debug("String_Node_Str");
  VisualRange vr=EditorData.getLastVisualRange(editor);
  if (vr == null) {
    return false;
  }
  logger.debug("String_Node_Str" + vr);
  CommandState.getInstance().pushState(CommandState.MODE_VISUAL,vr.getType(),KeyParser.MAPPING_VISUAL);
  visualStart=vr.getStart();
  visualEnd=vr.getEnd();
  visualOffset=vr.getOffset();
  updateSelection(editor,context,visualEnd);
  editor.getCaretModel().moveToOffset(visualOffset);
  editor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE);
  return true;
}
Program: 236
Project: 236
Buggy source:
public void selectionChanged(FileEditorManagerEvent event){
  if (CommandState.getInstance().getMode() == CommandState.MODE_VISUAL) {
    CommandGroups.getInstance().getMotion().exitVisual(EditorHelper.getEditor(event.getManager(),event.getOldFile()));
  }
}

Fixed version (ground truth):
public void selectionChanged(SelectionEvent selectionEvent){
  logger.debug("String_Node_Str" + selectionEvent.getOldRange() + "String_Node_Str"+ selectionEvent.getNewRange());
}
Program: 237
Project: 237
Buggy source:
/** 
 * Gets the virtual file associated with this editor
 * @param editor The editor
 * @return The virtual file for the editor
 */
public static VirtualFile getVirtualFile(Editor editor){
  VirtualFile file=(VirtualFile)editor.getUserData(FILE);
  if (file == null) {
    Project[] projs=ProjectManager.getInstance().getOpenProjects();
    for (int p=0; p < projs.length; p++) {
      FileEditorManager fMgr=FileEditorManager.getInstance(projs[p]);
      VirtualFile[] files=fMgr.getOpenFiles();
      for (int i=0; i < files.length; i++) {
        if (fMgr.fileToDocument(files[i]).equals(editor.getDocument())) {
          file=files[i];
          editor.putUserData(FILE,file);
          break;
        }
      }
    }
  }
  return file;
}

Fixed version (ground truth):
/** 
 * Gets the virtual file associated with this editor
 * @param editor The editor
 * @return The virtual file for the editor
 */
public static VirtualFile getVirtualFile(Editor editor){
  VirtualFile file=(VirtualFile)editor.getUserData(FILE);
  if (file == null) {
    Project[] projs=ProjectManager.getInstance().getOpenProjects();
    for (int p=0; p < projs.length; p++) {
      FileEditorManager fMgr=FileEditorManager.getInstance(projs[p]);
      VirtualFile[] files=fMgr.getOpenFiles();
      for (int i=0; i < files.length; i++) {
        Document doc=fMgr.fileToDocument(files[i]);
        if (doc != null && doc.equals(editor.getDocument())) {
          file=files[i];
          editor.putUserData(FILE,file);
          break;
        }
      }
    }
  }
  return file;
}
Program: 238
Project: 238
Buggy source:
public boolean execute(Editor editor,DataContext context,ExCommand cmd) throws ExException {
  KeyHandler.executeAction("String_Node_Str",context);
  return true;
}

Fixed version (ground truth):
public boolean execute(Editor editor,final DataContext context,ExCommand cmd) throws ExException {
  SwingUtilities.invokeLater(new Runnable(){
    public void run(){
      KeyHandler.executeAction("String_Node_Str",context);
    }
  }
);
  return true;
}
Program: 241
Project: 241
Buggy source:
public static CharBuffer getLineBuffer(Editor editor,int lline){
  return CharBuffer.wrap(editor.getDocument().getChars(),getLineStartOffset(editor,lline),getLineLength(editor,lline));
}

Fixed version (ground truth):
public static CharBuffer getLineBuffer(Editor editor,int lline){
  return CharBuffer.wrap(editor.getDocument().getChars(),getLineStartOffset(editor,lline),getLineCharCount(editor,lline));
}
Program: 242
Project: 242
Buggy source:
public GotoLineHandler(){
  super(null,"String_Node_Str",RANGE_REQUIRED | ARGUMENT_OPTIONAL,Command.FLAG_MOT_EXCLUSIVE);
}

Fixed version (ground truth):
/** 
 * Create the handler
 */
public GotoLineHandler(){
  super(RANGE_REQUIRED | ARGUMENT_OPTIONAL,Command.FLAG_MOT_EXCLUSIVE);
}
Program: 243
Project: 243
Buggy source:
public boolean execute(Editor editor,DataContext context,ExCommand cmd){
  int count=cmd.getLine(editor,context);
  if (count > 0) {
    MotionGroup.moveCaret(editor,context,CommandGroups.getInstance().getMotion().moveCaretToLineStartSkipLeading(editor,count - 1));
    return true;
  }
  return false;
}

Fixed version (ground truth):
/** 
 * Moves the cursor to the line entered by the user
 * @param editor The editor to perform the action in.
 * @param context The data context
 * @param cmd The complete Ex command including range, command, and arguments
 * @return True if able to perform the command, false if not
 */
public boolean execute(Editor editor,DataContext context,ExCommand cmd){
  int count=cmd.getLine(editor,context);
  if (count > 0) {
    MotionGroup.moveCaret(editor,context,CommandGroups.getInstance().getMotion().moveCaretToLineStartSkipLeading(editor,count));
    return true;
  }
  return false;
}
Program: 245
Project: 245
Buggy source:
/** 
 * Gets the number of ranges in the list
 * @return The range count
 */
public int size(){
  return count;
}

Fixed version (ground truth):
/** 
 * Gets the number of ranges in the list
 * @return The range count
 */
public int size(){
  return ranges.size();
}