Skip to content

Undo of a page rename fails after undoing the creation of a page with the old title #1296

Closed
logseq/logseq
#13449

Description

@yuxi-liu-wired

Steps

  1. Rename a page "page 1" to "alpha".
  2. Create a new page "page 1".
  3. Press Ctrl+Z. The new "page 1" goes to the Recycle bin.
  4. Press Ctrl+Z again.

Expected

The first page is named "page 1" again.

Actual

The second undo fails with Another page named "page 1" already exists for tags: #Page. The page stays "alpha", and the whole undo and redo history is cleared, so further Ctrl+Z does nothing.

Cause

Undo of the page creation recycles the new page, and a recycled page keeps its title (by design, #802). The undo of the rename saves the old title, and validate-unique-for-page (deps/outliner/src/logseq/outliner/validate.cljs) counts the recycled page as a duplicate. apply-history-action! turns the exception into reason :error, which frontend.worker.undo-redo/apply-history-action does not skip, so it clears the history.

This is the undo form of #1075. A fix needs a decision on 1 of these:

  1. A recycled page stops reserving its title for renames (Can't rename page title to title of a recently deleted page #1075).
  2. Undo of creating a page deletes the page for good when the undo removes the only reason it exists.
  3. An undo step that fails validation is skipped with a notification, and the history is kept.

Found with a property-based test of random outliner operation sequences with undo.

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