Bug 373716 - FastPartitioner cache breaks when Scanner has Partition based rules
Summary: FastPartitioner cache breaks when Scanner has Partition based rules
Status: RESOLVED WORKSFORME
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 4.2   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-Text-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: needinfo
Depends on:
Blocks:
 
Reported: 2012-03-08 17:35 EST by Mikkel Fishman CLA
Modified: 2012-03-19 05:43 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mikkel Fishman CLA 2012-03-08 17:35:55 EST
Build Identifier: Version: 3.7.0 Build id: I20110613-1736

I came across this bug when selecting a line of code and hitting tab in a custom editor, at which point all color formatting disappeared.

My PartitionScanner makes different decisions based on the previous partitions, so in it I ask for partitions in the document.

In FastPartitioner.initialize it calls clearPositionCache() before it asks the scanner for tokens. This function is called from computePartitioning(), which then proceeds to calculate partitions based on Position[] category=getPositions() which is set to return the cache if not null or the document positions if null.

Since my Scanner was asking for partitions in computing the tokens, it was setting the cache to an empty array, nullifying the purpose of clearing the cache in the first place. Then when it called getPosititions it returned the empty cache array and thus returned the entire document as one large partition.


I ended up subclassing off FastPartitioner and overriding initialize, clearing the cache AFTER the tokens are generated. This fixed the issue.

Reproducible: Always

Steps to Reproduce:
1. Have a PartitionScanner that calls document.getPartition
2. Have some sort of presentationreconciler attached to the document
3. Select a line of text and hit tab, which causes the whole document to be repartitioned.
Comment 1 Dani Megert CLA 2012-03-12 07:02:18 EDT
Please either provide a test case or steps that allow to reproduce it in the Eclipse SDK.
Comment 2 Dani Megert CLA 2012-03-19 05:43:29 EDT
Please reopen after attaching the requested details.