Skip to content

CodeRenderable.startHighlight() abort leaves renderer unscheduled #964

Closed

Description

@altendky

Symptom

When streaming content into a CodeRenderable and newer chunks arrive faster than the async highlighter can finish, the display may stall indefinitely if the renderer is otherwise idle (no animations, no input events). The stale highlight never gets re-attempted until an external requestRender() call occurs.

Root Cause

In CodeRenderable.startHighlight(), multiple snapshot-ID checks abort the method when a newer content chunk has arrived while highlighting was in-flight:

if (snapshotId !== this._highlightSnapshotId) {
  return
}

There are four such early returns (after highlightOnce, after onHighlight, after transformChunks, and in the catch block). On abort, the method returns without calling requestRender(). Since the preceding renderSelf() already cleared _highlightsDirty = false, and the aborted highlight doesn't reschedule, no new frame is queued. The next pending highlight is never started until something else externally triggers rendering.

Proposed Fix

Call this.requestRender() before each snapshot-mismatch early return inside startHighlight() so that the next frame can detect the still-dirty state and kick off the pending highlight.

Test Request

A test should verify that resolving a stale highlight (snapshot mismatch) still results in a subsequent requestRender() and a new highlight request.

Activity

  1. self-assigned this
    on Apr 22, 2026
  2. simonklee commented on Apr 22, 2026

    @simonklee
    Member

    Thanks. Ill have s look

  3. added
    bugSomething isn't working
    coreThis relates to the core package
    on Apr 30, 2026
  4. viralcodex commented on May 5, 2026

    @viralcodex
    Contributor

    Hi @altendky, can you tell me if you found a way to reproduce this? If yes, would love to know

  5. added a commit that references this issue on May 5, 2026
    89affc9
  6. altendky commented on May 5, 2026

    @altendky
    ContributorAuthor

    thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingcoreThis relates to the core package

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions