Skip to content

Bug: [lexical-y] With gc on, undoing a format removal while a collaborator applies the same format again takes it off the next character #9683

Open

Description

@zurfyx

Lexical version: main at 4a13388 (@lexical/y).

Steps To Reproduce

  1. Three clients bind one document holding the paragraphs "ab cd ef" and "next".
  2. Client A italicizes "b " and then removes the italic from "b" (two steps). Every client syncs.
  3. Offline from each other: client A undoes the removal, and client C italicizes "b" again.
  4. The clients sync.

Link to code example: packages/lexical-y/src/__tests__/unit/regressions/Formats.test.ts, describe "F30A-1", case "italic over "b ", italic removed from "b"; the removal undone ‖ "b" italic again". Run LEXICAL_Y_GC=1 pnpm exec vitest run --project unit packages/lexical-y/src/__tests__/unit/regressions/Formats.test.ts -t F30A-1. With LEXICAL_Y_GC=1 (Yjs garbage collection on, as products run) it fails for client id orders 1,2,3 / 3,2,1 / 2,3,1. Without it, it passes. With gc on it fails the same way on main before #9679 (cfcd3c4), so it is not from that change.

The current behavior

With gc on, every client and a fresh reader show "a" "b"[I] " cd ef": the space after "b", which nobody touched after A italicized it, loses its italic.

The expected behavior

"a" "b "[I] "cd ef", as with gc off: both changes give "b" its italic back, and the space keeps the italic from A's first step.

The harness ran every peer with gc off until #9679, so this cell never ran with gc on before; it is pinned as test.fails with gc on until fixed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions