@RequiresEdt // if you're going to remove this requirement, don't forget to make access to the fields thread-safe
    private void primaryCaretPositionPossiblyChanged(final @NotNull Caret currentPrimaryCaret) {
      final int currentPrimaryCaretDot = currentPrimaryCaret.getOffset();
      final int currentPrimaryCaretMark = currentPrimaryCaret.getLeadSelectionOffset();

      if (!myLastKnownPrimaryCaret.refersTo(currentPrimaryCaret)) {
        myLastKnownPrimaryCaret.clear();
        myLastKnownPrimaryCaret = new WeakReference<>(currentPrimaryCaret);
      }

      if (currentPrimaryCaretDot < 0) {
        LOG.error(
          "currentPrimaryCaretDot < 0",
          String.format("currentPrimaryCaretDot == %d", currentPrimaryCaretDot),
          String.format("currentPrimaryCaret == %s", currentPrimaryCaret)
        );
      }
      else if (currentPrimaryCaretMark < 0) { // I don't think it worth adding almost the same error twice, so it's an else-if
        LOG.error(
          "currentPrimaryCaretMark < 0",
          String.format("currentPrimaryCaretMark == %d", currentPrimaryCaretMark),
          String.format("currentPrimaryCaret == %s", currentPrimaryCaret)
        );
      }

      if ((myPrimaryCaretLastKnownDot == currentPrimaryCaretDot) && (myPrimaryCaretLastKnownMark == currentPrimaryCaretMark)) {
        // The position hasn't changed
        return;
      }

      myPrimaryCaretLastKnownDot = currentPrimaryCaretDot;
      myPrimaryCaretLastKnownMark = currentPrimaryCaretMark;

      fireCaretUpdate(new javax.swing.event.CaretEvent(EditorComponentImpl.this) {
        @Override
        public int getDot() {
          return currentPrimaryCaretDot;
        }

        @Override
        public int getMark() {
          return currentPrimaryCaretMark;
        }
      });
    }
@RequiresEdt // if you're going to remove this requirement, don't forget to make access to the fields thread-safe
    private void primaryCaretPositionPossiblyChanged(final @NotNull Caret currentPrimaryCaret)