void (@NotNull CaretEvent event) { // Removing a caret may cause a switching of the primary caret if (isInsideBulkUpdate()) { return; } final var currentPrimaryCaret = myEditor.getCaretModel().getPrimaryCaret(); if (myLastKnownPrimaryCaret.refersTo(currentPrimaryCaret)) { // The removal of a caret didn't cause a switching of the primary caret, so its position isn't supposed to have changed return; } primaryCaretPositionPossiblyChanged(currentPrimaryCaret); }