From b657872fcec50b84c7b95dbb0a6364a5450de8d8 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Fri, 23 Mar 2012 12:41:56 +0400 Subject: [PATCH] IDEA-83300: bulkUpdateStarted should be balanced against bulkUpdateFinished --- .../com/intellij/openapi/editor/impl/DocumentImpl.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/platform/core-impl/src/com/intellij/openapi/editor/impl/DocumentImpl.java b/platform/core-impl/src/com/intellij/openapi/editor/impl/DocumentImpl.java index e2a823c10e71..efbace051a9c 100644 --- a/platform/core-impl/src/com/intellij/openapi/editor/impl/DocumentImpl.java +++ b/platform/core-impl/src/com/intellij/openapi/editor/impl/DocumentImpl.java @@ -37,6 +37,7 @@ import com.intellij.util.LocalTimeCounter; import com.intellij.util.Processor; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.text.CharArrayUtil; +import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.TestOnly; @@ -631,7 +632,7 @@ public class DocumentImpl extends UserDataHolderBase implements DocumentEx { myCachedDocumentListeners = null; boolean success = myDocumentListeners.remove(listener); if (!success) { - LOG.error(String.format("Can't remove given document listener (%s). Registered listeners: %s", listener, myDocumentListeners)); + LOG.error("Can't remove document listener (" + listener + "). Registered listeners: "+myDocumentListeners); } } @@ -751,6 +752,10 @@ public class DocumentImpl extends UserDataHolderBase implements DocumentEx { @Override public final void setInBulkUpdate(boolean value) { ApplicationManager.getApplication().assertIsDispatchThread(); + if (myDoingBulkUpdate == value) { + // do not fire listeners or otherwise updateStarted() will be called more times than updateFinished() + return; + } myDoingBulkUpdate = value; myText.setDeferredChangeMode(value); if (value) { @@ -782,7 +787,7 @@ public class DocumentImpl extends UserDataHolderBase implements DocumentEx { @NotNull public String dumpState() { - StringBuilder result = new StringBuilder(); + @NonNls StringBuilder result = new StringBuilder(); result.append("deferred mode: ").append(myText.isDeferredChangeMode() ? "on" : "off"); result.append(", intervals:\n"); for (int line = 0; line < getLineCount(); line++) {