boolean () { final int rangeStart = myTextRangeMarker.getStartOffset(); final int rangeEnd = myTextRangeMarker.getEndOffset(); CharSequence textBefore = myDocument.getCharsSequence(); ApplicationManager.getApplication().runWriteAction(() -> CodeStyleManager.getInstance(myProject).reformatText(myFile, rangeStart, rangeEnd)); if (rangeStart != myTextRangeMarker.getStartOffset() || rangeEnd != myTextRangeMarker.getEndOffset()) { return true; } else { CharSequence fragmentBefore = textBefore.subSequence(rangeStart, rangeEnd); CharSequence fragmentAfter = myDocument.getCharsSequence().subSequence(rangeStart, rangeEnd); return !StringUtil.equals(fragmentBefore, fragmentAfter); } }