Backported fix for bug 209925.
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextEditor.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextEditor.java index 602a248..59c27e9 100644 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextEditor.java +++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextEditor.java
@@ -345,15 +345,17 @@ Runnable r= new Runnable() { public void run() { enableSanityChecking(true); - if (isStateValidated && fValidator != null) { - ISourceViewer viewer= fSourceViewer; - if (viewer != null) { - StyledText textWidget= viewer.getTextWidget(); - if (textWidget != null && !textWidget.isDisposed()) - textWidget.removeVerifyListener(fValidator); - fValidator= null; - enableStateValidation(false); + if (isStateValidated) { + if (fValidator != null) { + ISourceViewer viewer= fSourceViewer; + if (viewer != null) { + StyledText textWidget= viewer.getTextWidget(); + if (textWidget != null && !textWidget.isDisposed()) + textWidget.removeVerifyListener(fValidator); + fValidator= null; + } } + enableStateValidation(false); } else if (!isStateValidated && fValidator == null) { ISourceViewer viewer= fSourceViewer; if (viewer != null) { @@ -3786,8 +3788,9 @@ */ private void initializeSourceViewer(IEditorInput input) { - IAnnotationModel model= getDocumentProvider().getAnnotationModel(input); - IDocument document= getDocumentProvider().getDocument(input); + IDocumentProvider documentProvider= getDocumentProvider(); + IAnnotationModel model= documentProvider.getAnnotationModel(input); + IDocument document= documentProvider.getDocument(input); if (document != null) { fSourceViewer.setDocument(document, model); @@ -3796,8 +3799,12 @@ } if (fElementStateListener instanceof IElementStateListenerExtension) { + boolean isStateValidated= false; + if (documentProvider instanceof IDocumentProviderExtension) + isStateValidated= ((IDocumentProviderExtension)documentProvider).isStateValidated(input); + IElementStateListenerExtension extension= (IElementStateListenerExtension) fElementStateListener; - extension.elementStateValidationChanged(input, false); + extension.elementStateValidationChanged(input, isStateValidated); } if (fInitialCaret == null)