Skip to content

Validate document size before creating or replacing WaveEditor state #6

Open

Description

@LunaStev

Problem

WaveEditorDocument validates selection offsets in its constructor and replace, but does not enforce the character limit used by analyzeDocument and the default transform engine.

Both entry points accept 200,001 ASCII characters. A later apply('bold') rejects the already accepted document with WaveEditor documents may contain at most 200000 characters. A successful oversized replace also changes undo/redo history.

Reproduction

const content = 'x'.repeat(200_001)
new WaveEditorDocument(content) // currently succeeds

const document = new WaveEditorDocument('Wave')
document.replace(content)       // currently succeeds
await document.apply('bold')    // rejects

Completion criteria

  • Apply the existing Unicode character limit before constructor or replacement state is published.
  • A rejected replacement preserves the current snapshot and both history stacks.
  • Add core tests for exactly-at-limit and over-limit content, including supplementary Unicode characters.
  • Keep selection offsets in UTF-16 units and character counts in Unicode code points.
  • Reuse the existing limit and validation behavior without adding a separate configurable limit.

Difficulty: easy. Async transform ordering (#1) and surrogate-pair selection boundaries (#2) remain separate tasks.

Activity

  1. added
    bug
    good first issue
    help wanted
    on Sep 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    buggood first issuehelp wanted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions