Skip to content

Coalesce editor re-styles caused by preference bursts - #4360

Open
vogella wants to merge 1 commit into
eclipse-platform:masterfrom
vogella:lv/coalesce-editor-restyle
Open

Coalesce editor re-styles caused by preference bursts#4360
vogella wants to merge 1 commit into
eclipse-platform:masterfrom
vogella:lv/coalesce-editor-restyle

Conversation

@vogella

@vogella vogella commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

A theme switch writes every preference key on its own, and each key made every open editor re-run its presentation reconciler: AbstractTextEditor invalidated the whole document, SourceViewerDecorationSupport repainted the annotation painter over the highlighted range. With dozens of keys per switch that cost adds up per editor.

Both listeners now schedule at most one re-style per UI event loop turn, so a burst of preference changes costs one whole-document and one annotation re-style per editor instead of one per key. The painter's colors are still applied synchronously, only the repaint is deferred, so nothing is displayed with stale colors.

Verified that org.eclipse.ui.workbench.texteditor compiles. Note that in the theme-switch profile I took, the platform path this changes is only a small share of the stall; the bulk sits in JDT's semantic highlighting, which is eclipse-jdt/eclipse.jdt.ui#3142.

A theme switch writes every preference key individually, and two listeners per
editor reacted to each key by re-running the presentation reconciler:
AbstractTextEditor invalidated the whole document, SourceViewerDecorationSupport
repainted the annotation painter.

Both now schedule one re-style per UI event loop turn. The painter's colors are
still updated synchronously, only the repaint is deferred.

Assisted-by: multiple AI agents and layers of automated tooling 🤖
@BeckerWdf

Copy link
Copy Markdown
Member

That sounds interesting. But isn't this a general issue that preference changes are "published" one by one? The change looks like it "only" fixes the issue for text editors. What about other parts of the UI? Don't they suffer from the same issue? If yes: Can't we fix it at the central place once for everything (e.g. by changing preferences / publishing them in one bulk-call)?

@vogella

vogella commented Sep 8, 2026

Copy link
Copy Markdown
Contributor Author

That sounds interesting. But isn't this a general issue that preference changes are "published" one by one? The change looks like it "only" fixes the issue for text editors. What about other parts of the UI? Don't they suffer from the same issue? If yes: Can't we fix it at the central place once for everything (e.g. by changing preferences / publishing them in one bulk-call)?

Maybe. This would need a detailed analysis, changing such a central behavior is very dangerous.

@BeckerWdf

Copy link
Copy Markdown
Member

Maybe. This would need a detailed analysis

Ok. Let's see.

@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Test Results

   858 files  ±0     858 suites  ±0   49m 26s ⏱️ - 3m 49s
 8 302 tests ±0   8 059 ✅ ±0  243 💤 ±0  0 ❌ ±0 
20 775 runs  ±0  20 105 ✅ ±0  670 💤 ±0  0 ❌ ±0 

Results for commit 626fcd6. ± Comparison against base commit 73f7879.

@vogella
vogella marked this pull request as ready for review September 8, 2026 13:46
@vogella
vogella requested a balanced review from Copilot September 8, 2026 14:41

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The new coalescing contract needs regression coverage.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Coalesces editor restyling during preference bursts, complementing related JDT highlighting optimizations.

Changes:

  • Defers and coalesces full text-presentation invalidation.
  • Defers annotation repaint while applying colors synchronously.
File summaries
File Description
SourceViewerDecorationSupport.java Coalesces annotation painter repaints.
AbstractTextEditor.java Coalesces full-document presentation invalidations.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

* Re-styles the whole document once per UI event loop turn, so a burst of
* preference changes costs one re-style instead of one per key.
*/
private void invalidateTextPresentationLater() {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants