Program: 249
Project: 249
Buggy source:
/** 
 * This helper method calculates the complete range a motion will move over taking into account whether the motion is FLAG_MOT_LINEWISE or FLAG_MOT_CHARACTERWISE (FLAG_MOT_INCLUSIVE or FLAG_MOT_EXCLUSIVE).
 * @param editor The editor the motion takes place in
 * @param context The data context
 * @param count The count applied to the motion
 * @param rawCount The actual count entered by the user
 * @param argument Any argument needed by the motion
 * @param moveCursor True if cursor should be moved just as if motion command were executed by user, false if not
 * @return The motion's range
 */
public static TextRange getMotionRange(Editor editor,DataContext context,int count,int rawCount,Argument argument,boolean moveCursor){
  Command cmd=argument.getMotion();
  int cnt=cmd.getCount() * count;
  int raw=rawCount == 0 && cmd.getRawCount() == 0 ? 0 : cnt;
  MotionEditorAction action=(MotionEditorAction)cmd.getAction();
  int start=editor.getCaretModel().getOffset();
  int end=action.getOffset(editor,context,cnt,raw,cmd.getArgument());
  if (end == -1) {
    return null;
  }
  if (moveCursor) {
    moveCaret(editor,context,end);
  }
  int flags=cmd.getFlags();
  if ((flags & Command.FLAG_MOT_LINEWISE) != 0) {
    if (start > end) {
      int t=start;
      start=end;
      end=t;
    }
    start=EditorHelper.getLineStartForOffset(editor,start);
    end=Math.min(EditorHelper.getLineEndForOffset(editor,end) + 1,EditorHelper.getFileSize(editor));
  }
 else   if ((flags & Command.FLAG_MOT_INCLUSIVE) != 0) {
    end=end + (start <= end ? 1 : -1);
  }
  if (start > end) {
    int t=start;
    start=end;
    end=t;
  }
  return new TextRange(start,end);
}

Fixed version (ground truth):
/** 
 * This helper method calculates the complete range a motion will move over taking into account whether the motion is FLAG_MOT_LINEWISE or FLAG_MOT_CHARACTERWISE (FLAG_MOT_INCLUSIVE or FLAG_MOT_EXCLUSIVE).
 * @param editor The editor the motion takes place in
 * @param context The data context
 * @param count The count applied to the motion
 * @param rawCount The actual count entered by the user
 * @param argument Any argument needed by the motion
 * @param moveCursor True if cursor should be moved just as if motion command were executed by user, false if not
 * @return The motion's range
 */
public static TextRange getMotionRange(Editor editor,DataContext context,int count,int rawCount,Argument argument,boolean incNewline,boolean moveCursor){
  Command cmd=argument.getMotion();
  int cnt=cmd.getCount() * count;
  int raw=rawCount == 0 && cmd.getRawCount() == 0 ? 0 : cnt;
  MotionEditorAction action=(MotionEditorAction)cmd.getAction();
  int start=editor.getCaretModel().getOffset();
  int end=action.getOffset(editor,context,cnt,raw,cmd.getArgument());
  if (end == -1) {
    return null;
  }
  if (moveCursor) {
    moveCaret(editor,context,end);
  }
  int flags=cmd.getFlags();
  if ((flags & Command.FLAG_MOT_LINEWISE) != 0) {
    if (start > end) {
      int t=start;
      start=end;
      end=t;
    }
    start=EditorHelper.getLineStartForOffset(editor,start);
    end=Math.min(EditorHelper.getLineEndForOffset(editor,end) + (incNewline ? 1 : 0),EditorHelper.getFileSize(editor));
  }
 else   if ((flags & Command.FLAG_MOT_INCLUSIVE) != 0) {
    end=end + (start <= end ? 1 : -1);
  }
  if (start > end) {
    int t=start;
    start=end;
    end=t;
  }
  return new TextRange(start,end);
}