This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 159125 - CompoundHighlightsContainer does not do clipping as required
Summary: CompoundHighlightsContainer does not do clipping as required
Alias: None
Product: editor
Classification: Unclassified
Component: Painting & Printing (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: David Strupl
Depends on:
Reported: 2009-02-25 10:05 UTC by emi
Modified: 2009-04-29 10:40 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:

CompoundHighlightsContainer.updateCache patch to have proper clipping (2.46 KB, patch)
2009-02-25 10:10 UTC, emi
Details | Diff
New patch that has better checks. (3.95 KB, patch)
2009-03-12 17:27 UTC, emi
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description emi 2009-02-25 10:05:39 UTC
I found this bug while looking for the issue reported in #159122 . Basically it is possible to have layers in the
CompoundHighlightsContainer that are "broken" in various ways, which leads to corrupted coloring into the editor.

One of them is the fact that the sequence returned by getHighlights(int, int) must be clipped.

According to the HighlightsContainer.getHighlights javadoc: "any highlights outside of this range will be clipped by the
rendering infrastructure".

The problem is that this isn't respected by CompoundHighlightsContainer. More to the point the HighlightsSequence
returned by the layers in updateCache(...) is added "as-is" to the OffsetsBag.

This can lead to subtle repaint problems (like the one reported in #159122) where a broken layer can change the
OffsetsBag *outside* the [startOffset,endOffset] area, because there is no boundary check for this.

See the attached patch which fixes this by clipping to the boundary if a broken HighlightsSequence is detected.
Comment 1 emi 2009-02-25 10:10:08 UTC
Created attachment 77345 [details]
CompoundHighlightsContainer.updateCache patch to have proper clipping
Comment 2 emi 2009-03-12 17:27:11 UTC
Created attachment 78126 [details]
New patch that has better checks.
Comment 3 emi 2009-03-12 17:28:36 UTC
Just wanted to comment on the updated patch: I noticed situations where the returned highlights are totally outside the
[startOffset, endOffset] range so I need to check for that too.

Also, I'm not certain the HighlightsSequence is sorted by the start offset (though I assume it is?) so in my code I have
to loop over the underlying sequence.
Comment 4 David Strupl 2009-04-27 14:32:41 UTC
The patch has been applied to repo jet-main as changeset   : 128933:eafd5f2c2766.

Thanks for the contribution.
Comment 5 Vitezslav Stejskal 2009-04-29 10:40:01 UTC
With Emilian's patch in I discovered a problem in SyntaxHighlighting layer, which in some situations supplied unclipped
highlights or even highlights that were completely outside of the requested range. This should hopefully be remedied by