@Override
  public void setCaretsAndSelections(@NotNull List<? extends CaretState> caretStates) {
    if (caretStates.isEmpty()) throw new IllegalArgumentException("Empty list");
    CaretState state = caretStates.get(0);
    if (state != null) {
      if (state.getCaretPosition() != null) moveToLogicalPosition(state.getCaretPosition());
      if (state.getSelectionStart() != null && state.getSelectionEnd() != null) {
        myEditor.getSelectionModel().setSelection(myEditor.logicalPositionToOffset(state.getSelectionStart()), 
                                                  myEditor.logicalPositionToOffset(state.getSelectionEnd()));
      }
    }
  }
@Override
  public void setCaretsAndSelections(@NotNull List<? extends CaretState> caretStates)