void (@NotNull TemplateState templateState, Template template) { TextResult value = templateState.getVariableValue(PRIMARY_VARIABLE_NAME); myInsertedName = value != null ? value.toString().trim() : null; TextRange range = templateState.getCurrentVariableRange(); int currentOffset = myEditor.getCaretModel().getOffset(); if (range == null && myRenameOffset != null) { range = myRenameOffset.getTextRange(); } myBeforeRevert = range != null && range.getEndOffset() >= currentOffset && range.getStartOffset() <= currentOffset ? myEditor.getDocument().createRangeMarker(range.getStartOffset(), currentOffset) : null; if (myBeforeRevert != null) { myBeforeRevert.setGreedyToRight(true); } finish(true); }