void (int caretLineOffset) { int lineToInsertIndent = myDocument.getLineNumber(caretLineOffset); if (!lineContainsWhiteSpaceSymbolsOnly(lineToInsertIndent)) return; int lineToInsertStartOffset = myDocument.getLineStartOffset(lineToInsertIndent); if (lineToInsertIndent != getCurrentCaretLine()) { myCaretModel.moveToOffset(lineToInsertStartOffset); } myDocument.replaceString(lineToInsertStartOffset, caretLineOffset, myCaretIndentToRestore); }