Program: 232
Project: 232
Buggy source:
public void setVisualMode(Editor editor,DataContext context,int mode){
  int oldMode=CommandState.getInstance().getSubMode();
  if (mode == 0) {
    int start=editor.getSelectionModel().getSelectionStart();
    int end=editor.getSelectionModel().getSelectionEnd();
    if (start != end) {
      int line=editor.offsetToLogicalPosition(start).line;
      int lstart=EditorHelper.getLineStartOffset(editor,line);
      int lend=EditorHelper.getLineEndOffset(editor,line,true);
      logger.debug("String_Node_Str" + start + "String_Node_Str"+ end+ "String_Node_Str"+ lstart+ "String_Node_Str"+ lend);
      if (lstart == start && lend + 1 == end) {
        mode=Command.FLAG_MOT_LINEWISE;
      }
 else {
        mode=Command.FLAG_MOT_CHARACTERWISE;
      }
    }
  }
  if (oldMode == 0 && mode == 0) {
    editor.getSelectionModel().removeSelection();
    return;
  }
  if (mode == 0) {
    exitVisual(editor);
  }
 else {
    CommandState.getInstance().pushState(CommandState.MODE_VISUAL,mode,KeyParser.MAPPING_VISUAL);
  }
  KeyHandler.getInstance().reset();
  visualStart=editor.getSelectionModel().getSelectionStart();
  visualEnd=editor.getSelectionModel().getSelectionEnd();
  CommandGroups.getInstance().getMark().setMark(editor,context,'<',visualStart);
  CommandGroups.getInstance().getMark().setMark(editor,context,'>',visualEnd);
}

Fixed version (ground truth):
public void setVisualMode(Editor editor,DataContext context,int mode){
  logger.debug("String_Node_Str");
  int oldMode=CommandState.getInstance().getSubMode();
  if (mode == 0) {
    int start=editor.getSelectionModel().getSelectionStart();
    int end=editor.getSelectionModel().getSelectionEnd();
    if (start != end) {
      int line=editor.offsetToLogicalPosition(start).line;
      int lstart=EditorHelper.getLineStartOffset(editor,line);
      int lend=EditorHelper.getLineEndOffset(editor,line,true);
      logger.debug("String_Node_Str" + start + "String_Node_Str"+ end+ "String_Node_Str"+ lstart+ "String_Node_Str"+ lend);
      if (lstart == start && lend + 1 == end) {
        mode=Command.FLAG_MOT_LINEWISE;
      }
 else {
        mode=Command.FLAG_MOT_CHARACTERWISE;
      }
    }
  }
  if (oldMode == 0 && mode == 0) {
    editor.getSelectionModel().removeSelection();
    return;
  }
  if (mode == 0) {
    exitVisual(editor);
  }
 else {
    CommandState.getInstance().pushState(CommandState.MODE_VISUAL,mode,KeyParser.MAPPING_VISUAL);
  }
  KeyHandler.getInstance().reset();
  visualStart=editor.getSelectionModel().getSelectionStart();
  visualEnd=editor.getSelectionModel().getSelectionEnd();
  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;
    }
    visualEnd-=adj;
  }
  visualOffset=editor.getCaretModel().getOffset();
  logger.debug("String_Node_Str" + visualStart + "String_Node_Str"+ visualEnd);
  CommandGroups.getInstance().getMark().setMark(editor,context,'<',visualStart);
  CommandGroups.getInstance().getMark().setMark(editor,context,'>',visualEnd);
}