Skip to content

fix: reparent deck onto string-prefix sibling instead of no-op#5188

Draft
krMaynard wants to merge 2 commits into
ankitects:mainfrom
krMaynard:submit/deck-reparent
Draft

fix: reparent deck onto string-prefix sibling instead of no-op#5188
krMaynard wants to merge 2 commits into
ankitects:mainfrom
krMaynard:submit/deck-reparent

Conversation

@krMaynard

Copy link
Copy Markdown
Contributor

Linked issue (required)

Closes #5183

Summary / motivation (required)

reparented_name() used target.0.starts_with(&self.0) to detect a drop onto the dragged deck or one of its descendants. Because this compared the raw \x1f-joined names rather than component boundaries, a sibling whose name merely shares a string prefix (e.g. dragging foo::bar onto foo::barbaz) was misclassified as a descendant and the drop became a silent no-op.

The fix compares on \x1f component boundaries so only the deck itself or a genuine descendant is treated as a no-op.

Steps to reproduce (required, use N/A if not applicable)

  1. Create decks foo::bar and foo::barbaz.
  2. In the deck list, drag foo::bar onto foo::barbaz.
  3. Observe nothing happens (silent no-op) instead of bar becoming foo::barbaz::bar.

How to test (required)

Checklist (minimum)

  • I ran ./ninja check or an equivalent relevant check locally.
  • I added or updated tests when the change is non-trivial or behavior changed.

Details

Adds a regression assertion to the drag_drop test. The full CI workflow (check on Linux/macOS/Windows, format, minilints) was run against this exact commit on my fork: https://github.com/krMaynard/anki-fork/actions/runs/29983583656

Before / after behavior (optional)

Before: reparenting onto a string-prefix sibling is a silent no-op. After: it reparents correctly.

Risk / compatibility / migration (optional)

Low risk.

UI evidence (required for visual changes; otherwise N/A)

N/A

Scope

  • This PR is focused on one change (no unrelated edits).

reparented_name() used target.0.starts_with(&self.0) to detect a drop
onto the dragged deck or one of its descendants. Because this compared
the raw \x1f-joined names rather than component boundaries, a sibling
whose name merely shares a string prefix (e.g. dragging foo::bar onto
foo::barbaz) was misclassified as a descendant and the drop became a
silent no-op.

Compare on \x1f component boundaries so only the deck itself or a genuine
descendant is treated as a no-op. Adds a regression assertion to the
drag_drop test.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dragging deck onto string-prefix sibling is incorrectly a no-op

1 participant