void (@NotNull ChangeIndentContext context, int newIndent) { int caretOffset = context.editor.getCaretModel().getOffset(); String newIndentString = new IndentInfo(0, newIndent, 0).generateNewWhiteSpace(context.getIndentOptions()); int start = context.document.getLineStartOffset(context.targetLine); int end = DocumentUtil.getFirstNonSpaceCharOffset(context.document, context.targetLine); context.editor.getDocument().replaceString(start, end, newIndentString); if (caretOffset >= start && caretOffset < end) { context.editor.getCaretModel().moveToOffset(start + newIndentString.length()); } }