Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEtienne Reichenbach2018-07-13 14:15:46 +0000
committerEtienne Reichenbach2018-07-18 13:54:48 +0000
commit982b689404fbe86e68a1a36dd5460d4183fe9097 (patch)
tree8ad536a69e3c3e068fd54b4f51a16a58b20d4642 /org.eclipse.ui.workbench.texteditor
parent70121cc291f51eed06c87255a67b5dd2c61d64b7 (diff)
downloadeclipse.platform.text-982b689404fbe86e68a1a36dd5460d4183fe9097.tar.gz
eclipse.platform.text-982b689404fbe86e68a1a36dd5460d4183fe9097.tar.xz
eclipse.platform.text-982b689404fbe86e68a1a36dd5460d4183fe9097.zip
Bug 536952 - Avoid QuickDiff re-enabling in DocumentRewriteSessionEvent
* Only resume the DocumentLineDiffer if if was previously suspended by a DocumentRewriteSessionEvent. * Add a null check at AbstractDocument.stopRewriteSession(DocumentRewriteSession) to avoid a NullPointerException if startRewriteSession is not called before calling stopRewriteSession. The javadoc of stopRewriteSession says "This method has only any effect if startRewriteSession has been called before.", without the null-check the method had an effect if startRewriteSession was not called before, namely an NPE. Change-Id: Ia6f92c686c934e1c7cbb514e2c32ac055b557935 Signed-off-by: Etienne Reichenbach <etienner@gmail.com>
Diffstat (limited to 'org.eclipse.ui.workbench.texteditor')
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/DocumentLineDiffer.java20
1 files changed, 18 insertions, 2 deletions
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/DocumentLineDiffer.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/DocumentLineDiffer.java
index ac12e9cc0d2..5ab2dafd55e 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/DocumentLineDiffer.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/DocumentLineDiffer.java
@@ -213,14 +213,30 @@ public class DocumentLineDiffer implements ILineDiffer, IDocumentListener, IAnno
* @since 3.2
*/
private final IDocumentRewriteSessionListener fSessionListener= new IDocumentRewriteSessionListener() {
+
+ /**
+ * <code>true</code> if this line differ was suspended because of a
+ * {@link DocumentRewriteSessionEvent#SESSION_START session start} and
+ * needs to be resumed after a
+ * {@link DocumentRewriteSessionEvent#SESSION_STOP session stop} event,
+ * <code>false</code> otherwise.
+ */
+ private boolean fResumeOnRewriteSessionStop;
+
@Override
public void documentRewriteSessionChanged(DocumentRewriteSessionEvent event) {
if (event.getSession().getSessionType() == DocumentRewriteSessionType.UNRESTRICTED_SMALL)
return;
- if (DocumentRewriteSessionEvent.SESSION_START.equals(event.getChangeType()))
+ if (DocumentRewriteSessionEvent.SESSION_START.equals(event.getChangeType())) {
+ fResumeOnRewriteSessionStop = !isSuspended();
suspend();
- else if (DocumentRewriteSessionEvent.SESSION_STOP.equals(event.getChangeType()))
+ }
+ else if (fResumeOnRewriteSessionStop
+ && DocumentRewriteSessionEvent.SESSION_STOP.equals(event.getChangeType())) {
resume();
+ fResumeOnRewriteSessionStop= false;
+ }
+
}
};

Back to the top