int offset = getNextInsertionPoint(mouseX, selectionEnd, scrollDirection);
if (offset != -1) {
// If the next character is a paragraph terminator and is not the
// final terminator character, increment the selection
Document document = textArea.getDocument();
if (document.getCharacterAt(offset) == '\n'
&& offset < documentView.getCharacterCount() - 1) {
offset++;
}
textArea.setSelection(selectionStart, offset - selectionStart);