Skip to content

Commit 7790d47

Browse files
committed
Simple fix for NPE in ProjectionViewer.resetVisibleRegion
Only fix for places changed in ce17c9e and related to NPE's on `fProjectionAnnotationModel`. The code in `ProjectionViewer` in general assumes `fProjectionAnnotationModel` to be non null in most places where it might access it. Probably this needs to be revisited. Fixes #3459
1 parent ce17c9e commit 7790d47

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

bundles/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionViewer.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -776,7 +776,9 @@ public void setVisibleRegion(int start, int length) {
776776
expandOutsideCurrentVisibleRegion(document);
777777
collapseOutsideOfNewVisibleRegion(start, end, document);
778778
fConfiguredVisibleRegion= newVisibleRegion;
779-
hideProjectionAnnotationsOutsideOfVisibleRegion();
779+
if (fProjectionAnnotationModel != null) {
780+
hideProjectionAnnotationsOutsideOfVisibleRegion();
781+
}
780782
} catch (BadLocationException e) {
781783
ILog log= ILog.of(getClass());
782784
log.log(new Status(IStatus.WARNING, getClass(), IStatus.OK, null, e));
@@ -887,10 +889,12 @@ public void resetVisibleRegion() {
887889
super.resetVisibleRegion();
888890
}
889891
fConfiguredVisibleRegion= null;
890-
for (Iterator<Annotation> it= fProjectionAnnotationModel.getAnnotationIterator(); it.hasNext();) {
891-
Annotation annotation= it.next();
892-
if (annotation instanceof ProjectionAnnotation a) {
893-
a.setHidden(false);
892+
if (fProjectionAnnotationModel != null) {
893+
for (Iterator<Annotation> it= fProjectionAnnotationModel.getAnnotationIterator(); it.hasNext();) {
894+
Annotation annotation= it.next();
895+
if (annotation instanceof ProjectionAnnotation a) {
896+
a.setHidden(false);
897+
}
894898
}
895899
}
896900
}

0 commit comments

Comments
 (0)