Source:
<code>private boolean doit(int start, int length, String text, boolean fromDoc, boolean deletionOnly) { if (document == null) { initialize(); } printAnnotationsCount(); try { if ("".equals(text)) { if (!isEditableLine(start, length)) { return false; } Iterator<?> it = annotations.getAnnotationIterator(start, length, true, true); Position impactedArea = new Position(start, length); while (it.hasNext()) { GerritCommentAnnotation comment = (GerritCommentAnnotation) it.next(); Position commentPosition = annotations.getPosition(comment); try { if (commentPosition.length == 0 && (document.get(start, length).equals(textWidget.getLineDelimiter()))) { annotations.removeAnnotation(comment); return true; } } catch (BadLocationException e) { } if (!completelyIncludes(commentPosition, impactedArea)) { return false; } } return true; } if (deletionOnly) { return true; } if (!isEditableLine(start, text.length())) { int insertionPosition = start; String commentText = text.trim(); if (!fromDoc) { if (!isBeginningOfLine(insertionPosition)) { GerritCommentAnnotation currentAnnotation = getCurrentAnnotation(start); if (currentAnnotation != null) { Position position = annotations.getPosition(currentAnnotation); <START> insertionPosition = position.getOffset() + position.getLength() + 1; <END> } else { try { document.replace(textWidget.getCharCount(), 0, textWidget.getLineDelimiter()); } catch (BadLocationException e) { } insertionPosition = getNextLine(start); } } String insertedText = commentText + textWidget.getLineDelimiter(); try { document.replace(insertionPosition, 0, insertedText); } catch (BadLocationException e) { logger.debug("Exception inserting " + commentText, e); } textWidget.setCaretOffset( insertionPosition + insertedText.length() - textWidget.getLineDelimiter().length()); } annotations.addAnnotation(new GerritCommentAnnotation(null, commentText), new Position(insertionPosition, commentText.length())); return false; } return true; } finally { printAnnotationsCount(); } }</code><technical_language>I suggest insertionPosition = getNextLine(position.getOffset() + position.getLength());</technical_language>

Target:
private boolean doit(int start, int length, String text, boolean fromDoc, boolean deletionOnly) { if (document == null) { initialize(); } printAnnotationsCount(); try { if ("".equals(text)) { if (!isEditableLine(start, length)) { return false; } Iterator<?> it = annotations.getAnnotationIterator(start, length, true, true); Position impactedArea = new Position(start, length); while (it.hasNext()) { GerritCommentAnnotation comment = (GerritCommentAnnotation) it.next(); Position commentPosition = annotations.getPosition(comment); try { if (commentPosition.length == 0 && (document.get(start, length).equals(textWidget.getLineDelimiter()))) { annotations.removeAnnotation(comment); return true; } } catch (BadLocationException e) { } if (!completelyIncludes(commentPosition, impactedArea)) { return false; } } return true; } if (deletionOnly) { return true; } if (!isEditableLine(start, text.length())) { int insertionPosition = start; String commentText = text.trim(); if (!fromDoc) { if (!isBeginningOfLine(insertionPosition) || (isBeginningOfLine(insertionPosition) && getCurrentAnnotation(start) != null)) { GerritCommentAnnotation currentAnnotation = getCurrentAnnotation(start); if (currentAnnotation != null) { Position position = annotations.getPosition(currentAnnotation); insertionPosition = getNextLine(position.getOffset() + position.getLength()); } else { insertionPosition = getNextLine(start); } if (insertionPosition == -1) { try { document.replace(textWidget.getCharCount(), 0, textWidget.getLineDelimiter()); } catch (BadLocationException e) { } insertionPosition = getNextLine(start); } } String insertedText = commentText + textWidget.getLineDelimiter(); try { document.replace(insertionPosition, 0, insertedText); } catch (BadLocationException e) { logger.debug("Exception inserting " + commentText, e); } textWidget.setCaretOffset( insertionPosition + insertedText.length() - textWidget.getLineDelimiter().length()); } annotations.addAnnotation(new GerritCommentAnnotation(null, commentText), new Position(insertionPosition, commentText.length())); return false; } return true; } finally { printAnnotationsCount(); } }