Program: 196
Project: 196
Buggy source:
/** 
 * Process mouse clicks by setting/resetting visual mode. There are some strange scenarios to handle.
 * @param editor The editor
 * @param event  The mouse event
 */
private void processMouseClick(@NotNull Editor editor,@NotNull MouseEvent event){
  if (ExEntryPanel.getInstance().isActive()) {
    ExEntryPanel.getInstance().deactivate();
  }
  ExOutputModel.getInstance(editor).clear();
  CommandState.SubMode visualMode=CommandState.SubMode.NONE;
switch (event.getClickCount() % 3) {
case 1:
    visualMode=CommandState.SubMode.NONE;
  break;
case 2:
visualMode=CommandState.SubMode.VISUAL_CHARACTER;
break;
case 0:
visualMode=CommandState.SubMode.VISUAL_LINE;
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));
break;
}
setVisualMode(editor,visualMode);
switch (CommandState.getInstance(editor).getSubMode()) {
case NONE:
VisualPosition vp=editor.getCaretModel().getVisualPosition();
int col=EditorHelper.normalizeVisualColumn(editor,vp.line,vp.column,CommandState.getInstance(editor).getMode() == CommandState.Mode.INSERT || CommandState.getInstance(editor).getMode() == CommandState.Mode.REPLACE);
if (col != vp.column) {
editor.getCaretModel().moveToVisualPosition(new VisualPosition(vp.line,col));
}
MotionGroup.scrollCaretIntoView(editor);
break;
case VISUAL_CHARACTER:
editor.getCaretModel().moveToOffset(visualEnd);
break;
case VISUAL_LINE:
editor.getCaretModel().moveToLogicalPosition(editor.xyToLogicalPosition(event.getPoint()));
break;
}
visualOffset=editor.getCaretModel().getOffset();
EditorData.setLastColumn(editor,editor.getCaretModel().getVisualPosition().column);
}

Fixed version (ground truth):
/** 
 * Process mouse clicks by setting/resetting visual mode. There are some strange scenarios to handle.
 * @param editor The editor
 * @param event  The mouse event
 */
private void processMouseClick(@NotNull Editor editor,@NotNull MouseEvent event){
  if (ExEntryPanel.getInstance().isActive()) {
    ExEntryPanel.getInstance().deactivate(false);
  }
  ExOutputModel.getInstance(editor).clear();
  CommandState.SubMode visualMode=CommandState.SubMode.NONE;
switch (event.getClickCount() % 3) {
case 1:
    visualMode=CommandState.SubMode.NONE;
  break;
case 2:
visualMode=CommandState.SubMode.VISUAL_CHARACTER;
break;
case 0:
visualMode=CommandState.SubMode.VISUAL_LINE;
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));
break;
}
setVisualMode(editor,visualMode);
switch (CommandState.getInstance(editor).getSubMode()) {
case NONE:
VisualPosition vp=editor.getCaretModel().getVisualPosition();
int col=EditorHelper.normalizeVisualColumn(editor,vp.line,vp.column,CommandState.getInstance(editor).getMode() == CommandState.Mode.INSERT || CommandState.getInstance(editor).getMode() == CommandState.Mode.REPLACE);
if (col != vp.column) {
editor.getCaretModel().moveToVisualPosition(new VisualPosition(vp.line,col));
}
MotionGroup.scrollCaretIntoView(editor);
break;
case VISUAL_CHARACTER:
editor.getCaretModel().moveToOffset(visualEnd);
break;
case VISUAL_LINE:
editor.getCaretModel().moveToLogicalPosition(editor.xyToLogicalPosition(event.getPoint()));
break;
}
visualOffset=editor.getCaretModel().getOffset();
EditorData.setLastColumn(editor,editor.getCaretModel().getVisualPosition().column);
}