int (final Editor editor, int tailOffset) { Document document = editor.getDocument(); int textLength = document.getTextLength(); CharSequence chars = document.getCharsSequence(); if (tailOffset < textLength - 1 && chars.charAt(tailOffset) == ' ' && chars.charAt(tailOffset + 1) == '=') { return moveCaret(editor, tailOffset, 2); } if (tailOffset < textLength && chars.charAt(tailOffset) == '=') { return moveCaret(editor, tailOffset, 1); } if (isSpaceAroundAssignmentOperators(editor, tailOffset)) { document.insertString(tailOffset, " ="); tailOffset = moveCaret(editor, tailOffset, 2); tailOffset = insertChar(editor, tailOffset, ' '); } else { document.insertString(tailOffset, "="); tailOffset = moveCaret(editor, tailOffset, 1); } return tailOffset; }