chore(lint): repo-wide green becomes the contract
CI / ci (push) Canceled after 0s
CI / ci (push) Canceled after 0s
Close the lint arc #194-#197: deliberate-style rule disables with rationales (#194), filter-safe test renames + --test-case-name-format preserve (#195), every surviving warning fixed through the sanctioned lint-stable shapes (#196), and the docs now state the true contract (#197): bare swiftlint . reports zero violations and swiftformat . reformats nothing, while push gates stay scoped to the push's own files (settled #190 design) — the pre-push hook's stale 'pre-existing violations' rationale blocks refreshed, gate logic untouched. Also in the sweep: quiesce the FSEvent-burst watcher race in LibrarySearchTests (two rescans double-count one shared PostScanCache miss; benign revision over-bump), pin the learnings scan's symlink-skip contract (flip-verified — defended in depth by the lstat guard AND contentsOfDirectory's own symlink refusal), reorder that scan's guard so cheap rejections precede the directory listing, and park the roster chmod window with a ceiling comment. Finish-audit: 3 reviewers, 0 blocking; the one code finding was disproved by probe (&& out-binds ?? — the guard was correct). Suite 693/693 via scripts/full-test.sh; swiftlint 0 violations; swiftformat 0/141; hook rig 23/23. Closes #197
This commit is contained in:
1 parent
0ab00eb7b6
commit
d7fd11cf0d
29 files changed
+549
-269
No files matched your search
@@ -55,10 +55,7 @@ nonisolated enum OutlinePresenter {
|
||||
_ nodes: [OutlineNode], folded: Set<UUID>, zoomRootID: UUID? = nil,
|
||||
) -> [Row] {
|
||||
var rows: [Row] = []
|
||||
if let zoomRootID,
|
||||
let rootPath = path(of: zoomRootID, in: nodes),
|
||||
let root = node(at: rootPath, in: nodes)
|
||||
{
|
||||
if let zoomRootID, let rootPath = path(of: zoomRootID, in: nodes), let root = node(at: rootPath, in: nodes) {
|
||||
walk(root.children, parent: rootPath, depth: 0, folded: folded, into: &rows)
|
||||
} else {
|
||||
walk(nodes, parent: [], depth: 0, folded: folded, into: &rows)
|
||||
@@ -776,27 +773,14 @@ extension OutlineEditorView {
|
||||
}
|
||||
case let .hop(direction):
|
||||
// ↑/↓ hop VISIBLE blocks — folded subtrees are skipped.
|
||||
let rows = OutlinePresenter.visibleRows(nodes, folded: folded, zoomRootID: zoomStack.last)
|
||||
if let current = rows.firstIndex(where: { $0.id == focusedID }),
|
||||
rows.indices.contains(current + direction)
|
||||
{
|
||||
focusedID = rows[current + direction].id
|
||||
selectionAnchor = nil
|
||||
pendingCaret = nil // caret at end of the target row
|
||||
}
|
||||
hopFocus(direction, clearsAnchor: true)
|
||||
case let .extend(direction):
|
||||
// ⇧↑/⇧↓: extend the block selection one visible row. First
|
||||
// press anchors at the focused row; a bare ↑/↓ or click clears.
|
||||
if let focusedID {
|
||||
extendSelection(to: focusedID) // arm the anchor at the current focus
|
||||
}
|
||||
let rows = OutlinePresenter.visibleRows(nodes, folded: folded, zoomRootID: zoomStack.last)
|
||||
if let current = rows.firstIndex(where: { $0.id == focusedID }),
|
||||
rows.indices.contains(current + direction)
|
||||
{
|
||||
focusedID = rows[current + direction].id
|
||||
pendingCaret = nil
|
||||
}
|
||||
hopFocus(direction, clearsAnchor: false)
|
||||
case .deselect:
|
||||
_ = handleEscape() // selection first, then zoom — same order as the monitor
|
||||
case .indent, .outdent, .moveUp, .moveDown, .enter:
|
||||
@@ -804,20 +788,27 @@ extension OutlineEditorView {
|
||||
}
|
||||
}
|
||||
|
||||
/// Move focus `direction` visible rows from its current position (nil at
|
||||
/// the list edges — folded subtrees are skipped). `clearsAnchor`
|
||||
/// distinguishes hop (clears the block-selection anchor) from extend.
|
||||
private func hopFocus(_ direction: Int, clearsAnchor: Bool) {
|
||||
let rows = OutlinePresenter.visibleRows(nodes, folded: folded, zoomRootID: zoomStack.last)
|
||||
guard let current = rows.firstIndex(where: { $0.id == focusedID }),
|
||||
rows.indices.contains(current + direction)
|
||||
else { return }
|
||||
focusedID = rows[current + direction].id
|
||||
if clearsAnchor {
|
||||
selectionAnchor = nil
|
||||
}
|
||||
pendingCaret = nil // caret at end of the target row
|
||||
}
|
||||
|
||||
/// Tree-mutating ops (indent/outdent/move/enter). Serialize + route
|
||||
/// focus only when something actually changed (boundary no-ops are
|
||||
/// nil and leave the document alone).
|
||||
private func applyTree(_ op: OutlineRowTextView.StructureOp) {
|
||||
guard let focusedID else { return }
|
||||
// Block selection + batchable op → run-wide apply. Moves treat
|
||||
// the run as a unit (boundary leader no-ops the whole batch).
|
||||
if let anchor = selectionAnchor,
|
||||
let range = selectedRangeIDs(anchor: anchor, focus: focusedID), range.count > 1,
|
||||
let batchOp = map(op)
|
||||
{
|
||||
if OutlinePresenter.applyBatch(batchOp, ids: range, to: &nodes) {
|
||||
pushToDocument()
|
||||
}
|
||||
if applyBatchIfPossible(op, focus: focusedID) {
|
||||
return
|
||||
}
|
||||
guard let path = OutlinePresenter.path(of: focusedID, in: nodes) else { return }
|
||||
@@ -833,27 +824,52 @@ extension OutlineEditorView {
|
||||
case .moveDown:
|
||||
didChange = OutlineTree.move(&nodes, path: path, up: false) != nil
|
||||
case let .enter(caretGraphemes):
|
||||
switch OutlineTree.enter(&nodes, path: path, caretOffset: caretGraphemes) {
|
||||
case .noOp:
|
||||
break
|
||||
case let .outdented(newPath):
|
||||
didChange = newPath != nil // nil = boundary no-op
|
||||
case let .newNode(newPath, caret):
|
||||
didChange = true
|
||||
if let id = OutlinePresenter.node(at: newPath, in: nodes)?.id {
|
||||
newFocus = (id, caret)
|
||||
}
|
||||
}
|
||||
let enter = applyEnter(caretGraphemes: caretGraphemes, path: path)
|
||||
didChange = enter.didChange
|
||||
newFocus = enter.focus
|
||||
case .fold, .unfold, .hop, .extend, .deselect:
|
||||
return // unreachable — apply(_:) routes those to view state
|
||||
}
|
||||
if didChange {
|
||||
if let newFocus {
|
||||
self.focusedID = newFocus.id
|
||||
pendingCaret = newFocus.caret
|
||||
}
|
||||
commitIfChanged(didChange, newFocus)
|
||||
}
|
||||
|
||||
/// Serialize + route focus only when something actually changed.
|
||||
private func commitIfChanged(_ didChange: Bool, _ newFocus: (id: UUID, caret: Int)?) {
|
||||
guard didChange else { return }
|
||||
if let newFocus {
|
||||
focusedID = newFocus.id
|
||||
pendingCaret = newFocus.caret
|
||||
}
|
||||
pushToDocument()
|
||||
}
|
||||
|
||||
/// Block-selection fast path: a batchable op over a multi-row run
|
||||
/// (moves treat the run as a unit — a boundary leader no-ops the whole
|
||||
/// batch). Returns true when the batch ran (caller stops here).
|
||||
private func applyBatchIfPossible(_ op: OutlineRowTextView.StructureOp, focus: UUID) -> Bool {
|
||||
guard let anchor = selectionAnchor,
|
||||
let range = selectedRangeIDs(anchor: anchor, focus: focus), range.count > 1,
|
||||
let batchOp = map(op)
|
||||
else { return false }
|
||||
if OutlinePresenter.applyBatch(batchOp, ids: range, to: &nodes) {
|
||||
pushToDocument()
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
/// Split (⏎) at `path`: serialize through OutlineTree.enter; focus
|
||||
/// follows the NEW node when one was created (nil path = boundary
|
||||
/// no-op).
|
||||
private func applyEnter(caretGraphemes: Int, path: [Int]) -> (didChange: Bool, focus: (id: UUID, caret: Int)?) {
|
||||
switch OutlineTree.enter(&nodes, path: path, caretOffset: caretGraphemes) {
|
||||
case .noOp:
|
||||
return (false, nil)
|
||||
case let .outdented(newPath):
|
||||
return (newPath != nil, nil) // nil = boundary no-op
|
||||
case let .newNode(newPath, caret):
|
||||
let id = OutlinePresenter.node(at: newPath, in: nodes)?.id
|
||||
return (true, id.map { ($0, caret) })
|
||||
}
|
||||
}
|
||||
|
||||
/// The selected row ids in visible order (anchor↔focus, inclusive).
|
||||
|
||||
Reference in new issue
Block a user