void () { myMarkupModel.addErrorMarkerListener(new ErrorStripeListener() { @Override public void errorMarkerChanged(@NotNull ErrorStripeEvent e) { errorStripeMarkerChanged((RangeHighlighterEx)e.getHighlighter()); } }, myCaretModel); myDocumentMarkupModel.addMarkupModelListener(myCaretModel, myMarkupModelListener); myMarkupModel.addMarkupModelListener(myCaretModel, myMarkupModelListener); myDocument.addDocumentListener(myFoldingModel, myCaretModel); myDocument.addDocumentListener(myCaretModel, myCaretModel); myDocument.addDocumentListener(new EditorDocumentAdapter(), myCaretModel); myDocument.addDocumentListener(mySoftWrapModel, myCaretModel); myDocument.addDocumentListener(myMarkupModel, myCaretModel); myFoldingModel.addListener(mySoftWrapModel, myCaretModel); myInlayModel.addListener(myFoldingModel, myCaretModel); myInlayModel.addListener(myCaretModel, myCaretModel); myCaretModel.addCaretListener(new IndentsModelCaretListener(this)); myCaretModel.addCaretListener(new CaretListener() { @Override public void caretPositionChanged(@NotNull CaretEvent e) { if (myState.isStickySelection()) { int selectionStart = Math.min(myStickySelectionStart, getDocument().getTextLength()); mySelectionModel.setSelection(selectionStart, myCaretModel.getVisualPosition(), myCaretModel.getOffset()); } } @Override public void caretAdded(@NotNull CaretEvent e) { if (myPrimaryCaret != null) { myPrimaryCaret.updateVisualPosition(); // repainting old primary caret's row background } repaintCaretRegion(e); myPrimaryCaret = myCaretModel.getPrimaryCaret(); } @Override public void caretRemoved(@NotNull CaretEvent e) { repaintCaretRegion(e); myPrimaryCaret = myCaretModel.getPrimaryCaret(); // repainting new primary caret's row background myPrimaryCaret.updateVisualPosition(); } }); myCaretModel.addCaretListener(myMarkupModel, myCaretModel); mySoftWrapModel.addSoftWrapChangeListener(new SoftWrapChangeListener() { @Override public void recalculationEnds() { if (myCaretModel.isUpToDate()) { myCaretModel.updateVisualPosition(); } } @Override public void softWrapsChanged() { myGutterComponent.clearLineToGutterRenderersCache(); } }); myInlayModel.addListener(new InlayModel.SimpleAdapter() { @Override public void onUpdated(@NotNull Inlay<?> inlay, int changeFlags) { onInlayUpdated(inlay, changeFlags); } @Override public void onBatchModeFinish(@NotNull Editor editor) { onInlayBatchModeFinish(); } }, myCaretModel); myScrollingModel.addVisibleAreaListener(this::moveCaretIntoViewIfCoveredByToolWindowBelow); myScrollingModel.addVisibleAreaListener(myMarkupModel); PropertyChangeListener propertyChangeListener = e -> { if (Document.PROP_WRITABLE.equals(e.getPropertyName())) { myEditorComponent.repaint(); } }; myDocument.addPropertyChangeListener(propertyChangeListener); Disposer.register(myDisposable, () -> myDocument.removePropertyChangeListener(propertyChangeListener)); CodeStyleSettingsManager.getInstance(myProject).subscribe(this, myDisposable); myState.addPropertyChangeListener((event) -> { switch (event.getPropertyName()) { case EditorState.isInsertModePropertyName -> isInsertModeChanged(event); case EditorState.isColumnModePropertyName -> isColumnModeChanged(event); case EditorState.isOneLineModePropertyName -> isOneLineModeChanged(event); case EditorState.isEmbeddedIntoDialogWrapperPropertyName -> isEmbeddedIntoDialogWrapperChanged(event); case EditorState.verticalScrollBarOrientationPropertyName -> verticalScrollBarOrientationChanged(event); case EditorState.isStickySelectionPropertyName -> isStickySelectionChanged(event); case EditorState.myBorderPropertyName -> borderChanged(event); } }, myDisposable); }