Skip to content

Merge adjacent cells under the same decoration in the DOM renderer - #6337

Open
coldsmirk wants to merge 1 commit into
xtermjs:masterfrom
coldsmirk:dom-merge-decorated-cells
Open

coldsmirk wants to merge 1 commit into
xtermjs:masterfrom
coldsmirk:dom-merge-decorated-cells

Conversation

@coldsmirk

Copy link
Copy Markdown

The DOM renderer never merges a decorated cell into a span (!isDecorated in the merge check), so every decorated cell gets a <span> of its own. An addon that colours words with decorations (log levels, timestamps, addresses) turns a 23-character timestamp into 23 spans. In an app on 6.0.0 that does this, streaming a log in WebKit with the DOM renderer dropped from about 174 to 91 frames in 3 seconds, and the median frame gap while scrolling went from 16 to 37 ms. With this change both were back to what they are without decorations.

Cells now share a span when they are covered by the same single decoration, as cells with the same attributes already do. A cell under several decorations, or under a different decoration than the open span, still starts a new span. A decoration applies the same colours and the same xterm-decoration-top class to every cell it covers, and the other merge conditions (fg/bg/ext, selection, link hover, spacing, cursor, joined ranges) are checked as before.

Tests:

  • Three unit tests in DomRendererRowFactory.test.ts with the real DecorationService: cells under one decoration share a span (fails without the change), two adjacent decorations of the same colour stay separate spans, and overlapping decorations don't merge.
  • Unit tests, lint and tsc pass. I didn't run the Playwright suites locally.
  • In Chrome with the built bundle (DOM renderer, 18 rows with three decorations each): 739 spans before, 109 after, and the screenshots look the same.

Copilot AI balanced review requested due to automatic review settings November 18, 2026 12:53

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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

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.

2 participants