Skip to content

Undo of deleting a block leaves block references to it as plain text #1325

Open
logseq/logseq
#13786

Description

@yuxi-liu-wired

Steps

  1. In a block, type "target".
  2. In another block, type see (( and pick "target", so the block holds a reference to "target".
  3. Delete the block "target". The other block now reads "see target" as plain text.
  4. Press Ctrl+Z.

Expected

"target" is back, and the other block holds its reference to "target" again.

Actual

"target" is back, but the other block still reads "see target" as plain text, with no reference to "target".

Cause

Deleting a block also rewrites every ((uuid)) reference to it in other blocks' titles into the deleted block's text, and retracts those blocks' refs to it (build-retracted-tx in deps/db/src/logseq/db/common/delete_blocks.cljs, which ldb/transact! adds to the delete's transaction). The undo inverse (build-inverse-delete-blocks in deps/outliner/src/logseq/outliner/op/construct.cljc) inserts the deleted blocks again and holds nothing for the blocks whose titles were rewritten. Same family as #1302 (node property values that pointed at the deleted block) and #1310 (links to a deleted tag).

Found with a property-based test of random outliner operation sequences with undo and redo, replayed on upstream master 16c4ed1a0: the other block's raw title is edit ((<uuid of b2>)) with b2 in its refs before the delete, edit b2 after the delete, and still edit b2 with no refs after the undo. The same replay with the app's worker transaction pipeline registered (ldb/register-transact-pipeline-fn! worker-pipeline/transact-pipeline) gives the same result.

Activity

  1. yuxi-liu-wired commented on Oct 28, 2026

    @yuxi-liu-wired
    Author

    Fixed in logseq/logseq#13786 (fix(db): sync checksum and local graphs, page and tag names, orphaned pages, tag deletion, recycled values, and unreachable code). Its description has the cause and the test that pins it; it fails on current master and passes with the fix.

  2. 1 remaining item

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions