Skip to content

Commit

Permalink
Prevent NPE
Browse files Browse the repository at this point in the history
- Do not return `null` in `getOccurrences()`
- See GH-8028
  • Loading branch information
junichi11 committed Dec 13, 2024
1 parent 7d38f33 commit a3f691c
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ public void setCaretPosition(int position) {

@Override
public Map<OffsetRange, ColoringAttributes> getOccurrences() {
return range2Attribs;
// must not return null
return Collections.unmodifiableMap(range2Attribs);
}

@Override
Expand Down Expand Up @@ -99,9 +100,11 @@ public void run(Result result, SchedulerEvent event) {
return;
}

if (!node.getBoolean(MarkOccurencesSettings.KEEP_MARKS, true) || localRange2Attribs.size() > 0) {
//store the occurrences if not empty, return null in getOccurrences() otherwise
if (!node.getBoolean(MarkOccurencesSettings.KEEP_MARKS, true) || !localRange2Attribs.isEmpty()) {
//store the occurrences if not empty
range2Attribs = localRange2Attribs;
} else {
range2Attribs = Collections.emptyMap();
}
}

Expand Down

0 comments on commit a3f691c

Please sign in to comment.