protected void commentWrapParagraphOnInsert(IDocument document, DocumentCommand command)
        throws BadLocationException
    {

        int line = document.getLineOfOffset(command.offset);
        IRegion region = document.getLineInformation(line);
        int lineOffset = region.getOffset();
        int lineLength = region.getLength();

        String lineContents = document.get(lineOffset, lineLength);
        StringBuilder buffer = new StringBuilder(lineContents);
        int start = command.offset - lineOffset;
        int end = command.length + start;
        buffer.replace(start, end, command.text);

        // handle whitespace
        if (command.text != null && command.text.length() != 0 && command.text.trim().length() == 0) {

            String endOfLine = document.get(command.offset, lineOffset + lineLength - command.offset);

            // end of line
            if (endOfLine.length() == 0) {
                // move caret to next line
                flushCommand(document, command);

                if (isLineTooShort(document, line)) {
                    int[] caretOffset =
                        {
                            command.offset
                        };
                    commentWrapParagraphFromLine(document, line, caretOffset, false);
                    command.offset = caretOffset[0];
                    return;
                }

                // move caret to next line if possible
                if (line < document.getNumberOfLines() - 1 && isCommentLine(document, line + 1)) {
                    String lineDelimiter = document.getLineDelimiter(line);
                    String nextLinePrefix = commentExtractLinePrefix(document, line + 1);
                    command.offset += lineDelimiter.length() + nextLinePrefix.length();
                }
                return;

                // inside whitespace at end of line
            } else if (endOfLine.trim().length() == 0) {
                // simply insert space
                return;
            }
        }

        // change in prefix region
        String prefix = commentExtractLinePrefix(document, line);
        boolean wrapAlways = command.offset >= lineOffset && command.offset <= lineOffset + prefix.length();

        // must insert the text now because it may include whitespace
        flushCommand(document, command);

        if (wrapAlways || calculateDisplayedWidth(buffer.toString()) > getMargin() || isLineTooShort(document, line)) {
            int[] caretOffset =
                {
                    command.offset
                };
            commentWrapParagraphFromLine(document, line, caretOffset, wrapAlways);

            if (!wrapAlways) {
                command.offset = caretOffset[0];
            }
        }
    }
Guesses if the command operates within a newly created SQL multi-line comment or not. If in doubt, it will assume
that the SQL multi-line comment is new.
plugins/org.jkiss.dbeaver.ui.editors.sql/src/org/jkiss/dbeaver/ui/editors/sql/indent/SQLCommentAutoIndentStrategy.java