Fix TargetPlatformPresentationReconciler: stop scanning past damage end#2284
Open
vogella wants to merge 2 commits intoeclipse-pde:masterfrom
Open
Fix TargetPlatformPresentationReconciler: stop scanning past damage end#2284vogella wants to merge 2 commits intoeclipse-pde:masterfrom
vogella wants to merge 2 commits intoeclipse-pde:masterfrom
Conversation
Contributor
|
This pull request changes some projects for the first time in this development cycle. An additional commit containing all the necessary changes was pushed to the top of this PR's branch. To obtain these changes (for example if you want to push more changes) either fetch from your fork or apply the git patch. Git patchFurther information are available in Common Build Issues - Missing version increments. |
ad4c2fd to
e08d95d
Compare
The reconciler always scanned the full document (offset 0 to document.getLength()) on every keystroke to ensure multi-line XML comment rules are honoured. While scanning from offset 0 is required for correctness, scanning *past* the damage end is wasted work because the returned TextPresentation is bounded by the damage region and silently discards any style ranges beyond it. Change the upper bound of TextUtilities.computePartitioning() from document.getLength() to damage.getOffset() + damage.getLength(). This avoids scanning content whose results would be thrown away, while preserving the full-context scan from offset 0 that multi-line rules require. Add TargetPlatformPresentationReconcilerTest to verify correctness for the common cases: simple documents, partial damage regions, multi-line comments before the damage, and damage inside a multi-line comment. Fixes: eclipse-pde#2283 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
30a7061 to
c91f39e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #2283 (also related to eclipse-platform/eclipse.platform.ui#2276).
TargetPlatformPresentationReconciler.createPresentation()overrides the defaultPresentationReconcilerbehaviour to always scan from offset 0. This isnecessary to correctly handle multi-line XML comment rules (
<!-- ... -->):without the full context from the start of the document, a comment that opened
before the damaged region would not be recognised.
However, the scan was running all the way to
document.getLength()even thoughthe
TextPresentationreturned is constructed with the damage region as itsextent — meaning any style ranges added for content after the damage end are
silently discarded. This results in O(document length) work on the UI thread
for every keystroke, causing noticeable freezes in large
.targetfiles.Changes
TargetPlatformPresentationReconciler— change the upper bound ofTextUtilities.computePartitioning()fromdocument.getLength()todamage.getOffset() + damage.getLength(). Scanning still starts at offset 0(multi-line rule correctness is preserved); it just stops where it would have
discarded results anyway.
MANIFEST.MF(genericeditor.extension) — declareorg.eclipse.pde.genericeditor.extension.testsas a friend of thereconciler.presentationpackage so the new tests can subclass the reconciler.TargetPlatformPresentationReconcilerTest— new test class covering:Known limitation
For edits very close to the end of a large file the gain is small (the damage
end ≈ the document end). A more thorough fix — e.g. caching scanner state
between edits, using a real
IDocumentPartitionerfor comments, or movingreconciliation off the UI thread — is left for a follow-up.
Test plan
mvn clean compileon the two affected bundles)TargetPlatformPresentationReconcilerTestpasses in a running Eclipse test environmentAllTargetEditorTestscontinue to pass🤖 Generated with Claude Code