void (String newValue, int start, int end, int segmentNumber) { TextRange range = TextRange.create(start, end); if (!TextRange.from(0, getDocument().getCharsSequence().length()).contains(range)) { LOG.error("Diagnostic for EA-54980. Can't extract " + range + " range. " + presentTemplate(getTemplate()), CoreAttachmentFactory.createAttachment(getDocument())); } String oldText = range.subSequence(getDocument().getCharsSequence()).toString(); if (!oldText.equals(newValue)) { getSegments().setNeighboursGreedy(segmentNumber, false); getDocument().replaceString(start, end, newValue); int newEnd = start + newValue.length(); getSegments().replaceSegmentAt(segmentNumber, start, newEnd); getSegments().setNeighboursGreedy(segmentNumber, true); fixOverlappedSegments(segmentNumber); } }