@Override
      public void commandStarted(@NotNull CommandEvent event) {
        if (!isUndoOrRedoInProgress()) {
          myDocumentChangesTerminateTemplate = isCaretOutsideCurrentSegment(event.getCommandName());
          started = true;
        }
      }
@Override
      public void commandStarted(@NotNull CommandEvent event)