GutterIconRenderer (@NotNull final Side sourceSide, @NotNull final @NlsContexts.Tooltip String tooltipText, @NotNull final Icon icon) { return new DiffGutterRenderer(icon, tooltipText) { @Override protected void handleMouseClick() { if (myViewer.isStateIsOutOfDate()) return; if (!myViewer.isEditable(sourceSide.other(), true)) return; final Project project = myViewer.getProject(); final Document document = myViewer.getDocument(sourceSide.other()); DiffUtil.executeWriteCommand(document, project, DiffBundle.message("message.replace.change.command"), () -> { myViewer.replaceChange(myChange, sourceSide); myViewer.scheduleRediff(); }); // applyChange() will schedule rediff, but we want to try to do it in sync // and we can't do it inside write action myViewer.rediff(); } }; }