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

+43
View File
@@ -170,6 +170,49 @@ nonisolated enum OutlineTree {
return moved
}
/// #112 drag primitive: remove and return the whole subtree at `path`
/// (nil when the path doesn't resolve). The drag engine pulls moving
/// blocks out one at a time, re-resolving paths by id between pulls.
static func extract(_ nodes: inout [OutlineNode], path: [Int]) -> OutlineNode? {
var extracted: OutlineNode?
_ = withSiblings(of: path, in: &nodes) { siblings, index in
extracted = siblings.remove(at: index)
return true
}
return extracted
}
/// #112 drag primitive: insert `run` as consecutive siblings at `index`
/// in the children of `parentPath` (empty = the root array). The index
/// clamps to count (append); empty runs are refused. False when the
/// parent doesn't resolve.
@discardableResult
static func insertRun(
_ run: [OutlineNode], parentPath: [Int], index: Int, in nodes: inout [OutlineNode],
) -> Bool {
guard !run.isEmpty else { return false }
return withChildren(of: parentPath, in: &nodes) { siblings in
let slot = min(max(index, 0), siblings.count)
siblings.insert(contentsOf: run, at: slot)
return true
}
}
/// Runs `body` on the children array of the node at `path` (the root
/// array for an empty path). False when the path doesn't resolve.
private static func withChildren(
of path: [Int], in nodes: inout [OutlineNode], _ body: (inout [OutlineNode]) -> Bool,
) -> Bool {
if path.isEmpty {
return body(&nodes)
}
guard let first = path.first, nodes.indices.contains(first) else { return false }
let rest = Array(path.dropFirst())
return rest.isEmpty
? body(&nodes[first].children)
: withChildren(of: rest, in: &nodes[first].children, body)
}
/// Tab. Node at `path` becomes the LAST child of its previous sibling.
/// No previous sibling → no-op, returns nil.
static func indent(_ nodes: inout [OutlineNode], path: [Int]) -> [Int]? {