feat(outline): drag-reorder + zoom — S6 (#112)
CI / ci (push) Canceled after 0s

Pointer drag of a block run into any sibling seam or onto a block to
nest as its child (wf113 variant A: fat-gap 30/40/30 bands, seam
line at the future bullet column); the block selection rides the
drag, the moved run becomes the selection, and Esc cancels mid-gesture.
Double-click any bullet zooms to its children with breadcrumbs back
out. New OutlineTree extract/insertRun splice subtrees id-preserving;
the live row's NSTextView moved to OutlineRowTextView.

Audit round: the gesture is self-contained from arm time (strong
window + callback captures — a mid-drag scroll that drops the origin
row cannot strand drag state), a second arming cancels a stuck
predecessor, rowFrames prefers the grip frame, hitTestDrop is y-up
only, and the rails read DropGeometry. Pinned in OutlineDragTests
(monitors fire on sendEvent with a real window number).

[Generated by AI]
This commit is contained in:
AlexKucera committed 2026-10-16 14:49:57 +02:00
1 parent d722820fc8
commit 21e2f27450
14 files changed
+2196 -256

No files matched your search

+37
View File
@@ -270,4 +270,41 @@ struct OutlineTreeTests {
#expect(!OutlineTree.parsesWithLoss("- one\n\n- two\n"))
#expect(!OutlineTree.parsesWithLoss(""))
}
// #112 (S6): the drag primitives — extract + insertRun.
@Test func `extract removes and returns the whole subtree by path`() {
var nodes = OutlineTree.parse("- a\n - a1\n- b").nodes
let extracted = OutlineTree.extract(&nodes, path: [0])
#expect(extracted?.text == "a")
#expect(extracted?.children.map(\.text) == ["a1"])
#expect(nodes.map(\.text) == ["b"])
// ids travel — the drag run re-inserts the same identities
#expect(extracted?.children[0].id != nil)
// unresolvable paths are nil no-ops
#expect(OutlineTree.extract(&nodes, path: [5]) == nil)
#expect(nodes.map(\.text) == ["b"])
}
@Test func `insertRun splices siblings at any parent and clamps the index`() {
var nodes = OutlineTree.parse("- a\n - a1\n- b").nodes
// into the root, before b
#expect(OutlineTree.insertRun([OutlineNode(text: "x")], parentPath: [], index: 1, in: &nodes))
#expect(nodes.map(\.text) == ["a", "x", "b"])
// a nested parent; index clamps to count (append)
#expect(OutlineTree.insertRun([OutlineNode(text: "a2")], parentPath: [0], index: 99, in: &nodes))
#expect(nodes[0].children.map(\.text) == ["a1", "a2"])
// a whole run lands contiguous, in order
let run = [OutlineNode(text: "r1"), OutlineNode(text: "r2")]
#expect(OutlineTree.insertRun(run, parentPath: [], index: 0, in: &nodes))
#expect(nodes.map(\.text) == ["r1", "r2", "a", "x", "b"])
// unresolvable parent → false, untouched; empty run refused
#expect(!OutlineTree.insertRun([OutlineNode(text: "z")], parentPath: [7], index: 0, in: &nodes))
#expect(!OutlineTree.insertRun([], parentPath: [], index: 0, in: &nodes))
#expect(nodes.map(\.text) == ["r1", "r2", "a", "x", "b"])
}
}