Skip to content

Whether a page rename is refused depends on whether the page has a parent #1346

Description

@yuxi-liu-wired

Steps

A rename there and back is refused:

  1. Press Cmd+K (Ctrl+K), type "Baz", and create the page.
  2. Create "Foo/Baz" the same way. Both pages exist, "Baz" and Foo/Baz's "Baz".
  3. On the page "Baz", change the title to "Qux", then back to "Baz".

A rename makes 2 top-level pages with 1 title:

  1. Create the page "Baz".
  2. Create "Foo/Bar" (the Library now holds Foo).
  3. On the page "Foo", change the title to "Baz".

The same holds for tags: create the tag "#Foo", then the tag "#Bar/Foo"; renaming the first "Foo" to "Qux" and back is refused with "Another tag named "Foo" already exists".

Expected

Step 3 of the first case is accepted: it gives back the graph of step 2, which Logseq allowed. db-test#272 was fixed so that pages with different parents may share a name, for create and rename alike.

Step 3 of the second case is refused, like renaming any page without a parent to "Baz", and like Cmd+K's create of "Baz", which opens the existing "Baz".

Actual

The first rename back is refused: "Another page named "Baz" already exists for tags: #Page". The page stays "Qux".

The second rename is accepted: 2 top-level pages titled "Baz", one of them in the Library.

Cause

validate-unique-for-page (deps/outliner/src/logseq/outliner/validate.cljs:49-123) picks its query by whether the page has a :block/parent. A page without a parent is compared with every page that has the title and a common tag, namespace children included. A page with a parent is compared only with its siblings. Top-level pages come in 2 kinds: a page created by name has no parent, while a namespace root has the Library as its parent (page-with-parent-and-order, deps/outliner/src/logseq/outliner/page.cljs:308-316; the worker pipeline also moves a page into the Library when a page is created under it, toggle-page-and-block in src/main/frontend/worker/pipeline.cljs). Tags have no parent, so a tag is always compared with every tag, while create-tag of "Bar/Foo" makes a second "Foo" under Bar (db-test#466 was closed by showing a tag's parent in the picker).

Found by the page model property test (frontend.worker.page-model-property-test, branch test/page-model-fuzz) on upstream master 16c4ed1a0. Its conjugation check renames a page to a new title and back and expects the graph as it was; its uniqueness check (no 2 live ordinary pages share a name at the top level) catches the second case. Shortest sequences: FUZZ_REPLAY='[[:rename 0 8 0] [:create 9 0 0]]' (first case), FUZZ_REPLAY='[[:rename 0 8 0] [:create 5 0 0] [:rename 1 8 0]]' (second case), FUZZ_REPLAY='[[:tag-new 0 0 0] [:create-tag 7 0 0]]' (tags).

No activity

Activity on this issue will appear here.

Activity

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