refactor(lint): clear the last five error spots (#147)
CI / ci (push) Canceled after 0s
CI / ci (push) Canceled after 0s
The repo contract "SwiftFormat + SwiftLint must both stay clean" had five error spots left beyond #146's PostsModel split, all mechanical. PostStore's enum body spanned 354 against 350 — the cursor-sidecar group (#66: CursorState + stateURL/readCursor/writeCursor, already its own MARK section) moves verbatim into a same-file nonisolated extension slotted chronologically before the #141 ingest MARK; the enum body lands at 334 and PostStore.CursorState keeps its qualified name, so no caller changes. Six single-char locals in ProseListTextView's dropIndex/rectY/isGap get real names (plus lo/hi in the same function — same violation class), one in ImageIngestTests' bandedRectY. The 194-char guard in ProseList.indent and the 221-char guard in OutlineEditorView.endDrag wrap in the house else-carries-the-brace form (#142 landmine avoided). PostStoreTests crossed its 1000-line ceiling at 1061 — split at the Pass substrate MARK per the MicropubModelTests precedent: the pass-adjacent write sides (#24/#29/#31) move byte-identical into PostStorePassTests.swift, shared helpers storeHome/readPost/readPiece stay internal in the original, and the #29 scenario header travels with its tests. 63 tests in, 63 out. The split's new parallel schedule exposed two latent test races, reproduced idle (~50% for the first) and fixed at the root: EditorSessionTests' sidecar poll inherited loop 1's deadline and timed out holding flush 1's default-zero sidecar (zeros, never nil — the telltale) — each loop now arms its own. SessionLifecycleTests' three stderrTail asserts raced the client's main-queue stderr drain (the #30 class) — a drainStderr bounded poll now precedes each. swiftlint reports zero errors on both targets; residual warning-tier notices match the standing #146 posture (the error tier is the bar; the one new notice is PostStorePassTests at 473/400 — a 1070-line suite cannot split into two files both under 400). swiftformat clean. Full suite 574/574 by xcresult executed count (573 unit + 1 UI smoke), twice consecutively plus the finish-up rerun. Closes #147
This commit is contained in:
1 parent
012f91727f
commit
4606fd4628
13 files changed
+639
-526
No files matched your search
@@ -295,37 +295,37 @@ final class ProseListTextView: NSTextView {
|
||||
guard length > 0 else { return 0 }
|
||||
var lastAbove: Int?
|
||||
var firstInBand = -1
|
||||
for s in 0 ... sampleCount {
|
||||
let i = min(length - 1, s * length / sampleCount)
|
||||
let y = rectY(i)
|
||||
guard y >= bandMinY, y <= bandMaxY else { continue }
|
||||
for sample in 0 ... sampleCount {
|
||||
let index = min(length - 1, sample * length / sampleCount)
|
||||
let sampleY = rectY(index)
|
||||
guard sampleY >= bandMinY, sampleY <= bandMaxY else { continue }
|
||||
if firstInBand < 0 {
|
||||
firstInBand = i
|
||||
firstInBand = index
|
||||
}
|
||||
if y >= targetY {
|
||||
lastAbove = i // at-or-above the drop on screen
|
||||
} else if let above = lastAbove, above < i {
|
||||
// Bracket [above, i] straddles the drop; both ends are
|
||||
if sampleY >= targetY {
|
||||
lastAbove = index // at-or-above the drop on screen
|
||||
} else if let above = lastAbove, above < index {
|
||||
// Bracket [above, index] straddles the drop; both ends are
|
||||
// in-band (laid out, monotone) so the search probes real rects.
|
||||
var lo = above
|
||||
var hi = i
|
||||
while lo < hi {
|
||||
let mid = (lo + hi) / 2
|
||||
var lowerBound = above
|
||||
var upperBound = index
|
||||
while lowerBound < upperBound {
|
||||
let mid = (lowerBound + upperBound) / 2
|
||||
if rectY(mid) >= targetY {
|
||||
lo = mid + 1
|
||||
lowerBound = mid + 1
|
||||
} else {
|
||||
hi = mid
|
||||
upperBound = mid
|
||||
}
|
||||
}
|
||||
return min(lo, length)
|
||||
return min(lowerBound, length)
|
||||
}
|
||||
}
|
||||
return min(lastAbove ?? max(firstInBand, 0), length)
|
||||
}
|
||||
|
||||
private func rectY(_ i: Int, of length: Int) -> CGFloat {
|
||||
guard window != nil, i >= 0, i < length else { return -1 } // viewless (tests): land at index 0
|
||||
return firstRect(forCharacterRange: NSRange(location: i, length: 1), actualRange: nil).midY
|
||||
private func rectY(_ charIndex: Int, of length: Int) -> CGFloat {
|
||||
guard window != nil, charIndex >= 0, charIndex < length else { return -1 } // viewless (tests): land at index 0
|
||||
return firstRect(forCharacterRange: NSRange(location: charIndex, length: 1), actualRange: nil).midY
|
||||
}
|
||||
|
||||
/// #141's SwiftUI entry — the window `.dropDestination`'s perform
|
||||
@@ -357,14 +357,14 @@ final class ProseListTextView: NSTextView {
|
||||
targetY: mouse.y,
|
||||
bandMinY: screenVisible.minY,
|
||||
bandMaxY: screenVisible.maxY,
|
||||
) { i in
|
||||
rectY(i, of: length)
|
||||
) { charIndex in
|
||||
rectY(charIndex, of: length)
|
||||
}
|
||||
// Never splice inside a word or link — slide to the next gap
|
||||
// (a drop ON an existing ref appends after it, dogfood 2026-11-02).
|
||||
let buffer = string as NSString
|
||||
func isGap(_ c: unichar) -> Bool {
|
||||
guard let scalar = Unicode.Scalar(Int(c)) else { return false }
|
||||
func isGap(_ char: unichar) -> Bool {
|
||||
guard let scalar = Unicode.Scalar(Int(char)) else { return false }
|
||||
return CharacterSet.whitespacesAndNewlines.contains(scalar)
|
||||
}
|
||||
if index > 0, index < length,
|
||||
|
||||
Reference in new issue
Block a user