diff --git a/Museion/LearningsPaneView.swift b/Museion/LearningsPaneView.swift index ed9cbf6..5efbdf3 100644 --- a/Museion/LearningsPaneView.swift +++ b/Museion/LearningsPaneView.swift @@ -75,8 +75,7 @@ nonisolated enum LearningsIndex { ) else { return [] } var groups: [Group] = [] for dir in typeDirs.sorted(by: { $0.lastPathComponent < $1.lastPathComponent }) { - guard isPlainDirectory(dir), !dir.lastPathComponent.hasPrefix(".") else { continue } - guard let files = try? FileManager.default.contentsOfDirectory(at: dir, includingPropertiesForKeys: nil) + guard isPlainDirectory(dir), !dir.lastPathComponent.hasPrefix("."), let files = try? FileManager.default.contentsOfDirectory(at: dir, includingPropertiesForKeys: nil) else { continue } // #27: the pass clock feeds the decay verdict — clocked dirs // carry their count, foreign dirs nil (no verdict; Entry's audit). diff --git a/Museion/MentorSessionModel.swift b/Museion/MentorSessionModel.swift index 499271e..7227ae9 100644 --- a/Museion/MentorSessionModel.swift +++ b/Museion/MentorSessionModel.swift @@ -728,8 +728,8 @@ extension MentorSessionModel { guard method == "session/update", let params, let sid = params.objectValue?["sessionId"]?.stringValue, - transcripts[sid] != nil else { return } - guard let update = params.objectValue?["update"]?.objectValue else { return } + transcripts[sid] != nil, + let update = params.objectValue?["update"]?.objectValue else { return } let kind = update["sessionUpdate"]?.stringValue ?? "unknown" let replaying = sid == replayingSessionId switch kind { diff --git a/Museion/OutlineEditorView.swift b/Museion/OutlineEditorView.swift index 2918bd7..c9cab46 100644 --- a/Museion/OutlineEditorView.swift +++ b/Museion/OutlineEditorView.swift @@ -678,11 +678,7 @@ extension OutlineEditorView { private func endDrag(at point: CGPoint?, frames: [UUID: CGRect]?) { let info = drag drag = nil - guard let point, let info, let frames else { return } - guard let target = OutlinePresenter.hitTestDrop(point: point, rows: materializedRows(frames: frames)) else { - return - } - guard OutlinePresenter.applyDrop(target, moving: info.moving, in: &nodes) else { return } + guard let point, let info, let frames, let target = OutlinePresenter.hitTestDrop(point: point, rows: materializedRows(frames: frames)), OutlinePresenter.applyDrop(target, moving: info.moving, in: &nodes) else { return } selectionAnchor = info.moving.first focusedID = info.moving.last pendingCaret = nil diff --git a/Museion/PostLibrary.swift b/Museion/PostLibrary.swift index 47cb3d0..aceb476 100644 --- a/Museion/PostLibrary.swift +++ b/Museion/PostLibrary.swift @@ -77,18 +77,17 @@ nonisolated struct Post: Identifiable, Equatable { for projectDir in projects.sorted(by: { $0.lastPathComponent < $1.lastPathComponent }) { let values = try? projectDir.resourceValues(forKeys: [.isDirectoryKey, .isSymbolicLinkKey]) guard values?.isDirectory ?? false, !(values?.isSymbolicLink ?? false), - !projectDir.lastPathComponent.hasPrefix(".") else { continue } - guard let entries = try? FileManager.default.contentsOfDirectory( - at: projectDir, - includingPropertiesForKeys: [.isDirectoryKey, .isSymbolicLinkKey], - ) else { continue } + !projectDir.lastPathComponent.hasPrefix("."), + let entries = try? FileManager.default.contentsOfDirectory( + at: projectDir, + includingPropertiesForKeys: [.isDirectoryKey, .isSymbolicLinkKey], + ) else { continue } for dir in entries.sorted(by: { $0.lastPathComponent < $1.lastPathComponent }) { let pieceValues = try? dir.resourceValues(forKeys: [.isDirectoryKey, .isSymbolicLinkKey]) guard pieceValues?.isDirectory ?? false, !(pieceValues?.isSymbolicLink ?? false), !dir.lastPathComponent.hasPrefix(".") else { continue } let fileURL = dir.appendingPathComponent("post.md") - guard let text = try? String(contentsOf: fileURL, encoding: .utf8) else { continue } - guard seen.insert(dir.lastPathComponent).inserted else { continue } + guard let text = try? String(contentsOf: fileURL, encoding: .utf8), seen.insert(dir.lastPathComponent).inserted else { continue } let frontmatter = frontmatter(of: text) posts.append( Post( diff --git a/Museion/PostStore.swift b/Museion/PostStore.swift index 6ec9088..d11c2d8 100644 --- a/Museion/PostStore.swift +++ b/Museion/PostStore.swift @@ -682,9 +682,9 @@ nonisolated extension PostStore { } try FileManager.default.createDirectory(at: research, withIntermediateDirectories: true) let day = FixCardStore.formatted(Date(), "yyyyMMdd") - /// Flat single-line structural fields (Learning-file precedent): a - /// newline in a hostile title/url must not break the heading or the - /// frontmatter shape. Note/quote stay verbatim — they are content. + // Flat single-line structural fields (Learning-file precedent): a + // newline in a hostile title/url must not break the heading or the + // frontmatter shape. Note/quote stay verbatim — they are content. func flat(_ value: String) -> String { value.components(separatedBy: .newlines).joined(separator: " ") } diff --git a/Museion/PostsModel.swift b/Museion/PostsModel.swift index a7b712b..1bbf73a 100644 --- a/Museion/PostsModel.swift +++ b/Museion/PostsModel.swift @@ -603,8 +603,7 @@ final class PostsModel { /// main actor already; no re-hop needed. private func startExternalWatch(url: URL) { externalWatcher.onEvent = { [weak self] in - guard let self, let session = externalSession else { return } - guard let disk = try? String(contentsOf: url, encoding: .utf8) else { return } + guard let self, let session = externalSession, let disk = try? String(contentsOf: url, encoding: .utf8) else { return } session.diskDidChange(diskText: disk) } externalWatcher.start(urls: [url.deletingLastPathComponent()]) diff --git a/Museion/ProseList.swift b/Museion/ProseList.swift index ba33228..42f8efd 100644 --- a/Museion/ProseList.swift +++ b/Museion/ProseList.swift @@ -88,8 +88,7 @@ nonisolated enum ProseList { guard buffer.length > 0 else { return nil } let scanned = lines(in: text) let caretLoc = min(max(0, caret), buffer.length - 1) - guard let idx = scanned.firstIndex(where: { NSLocationInRange(caretLoc, $0.range) }) else { return nil } - guard scanned[idx].isList else { return nil } + guard let idx = scanned.firstIndex(where: { NSLocationInRange(caretLoc, $0.range) }), scanned[idx].isList else { return nil } let indent = scanned[idx].indent let bounds = blockBounds(scanned, from: idx, indent: indent) let blockEnd = scanned[bounds.end].end @@ -154,8 +153,7 @@ nonisolated extension ProseList { /// minus our indent. No previous sibling → nil (boundary no-op). static func indent(_ item: Item, caret: Int, in text: String) -> Edit? { let scanned = lines(in: text) - guard let idx = lineIndex(of: item.markerLine.location, in: scanned) else { return nil } - guard let sibIdx = adjacentSiblingLine(scanned, from: idx, through: idx, indent: item.indent, direction: -1) else { return nil } + guard let idx = lineIndex(of: item.markerLine.location, in: scanned), let sibIdx = adjacentSiblingLine(scanned, from: idx, through: idx, indent: item.indent, direction: -1) else { return nil } let delta = contentColumn(scanned[sibIdx].text) - item.indent guard delta > 0 else { return nil } let body = blockBody(text, item.block) diff --git a/Museion/ProsePresenter.swift b/Museion/ProsePresenter.swift index 454e2e2..bd198c1 100644 --- a/Museion/ProsePresenter.swift +++ b/Museion/ProsePresenter.swift @@ -435,7 +435,7 @@ nonisolated enum ProsePresenter { static let inlineSyntax: Set = ["*", "_", "`", "[", "]", "(", ")", "!", "<", ">"] } -nonisolated extension Range where Bound == String.Index { +nonisolated extension Range { func utf16Range(in base: String) -> Range { let lo = base.utf16.distance(from: base.utf16.startIndex, to: lowerBound.samePosition(in: base.utf16)!) let hi = base.utf16.distance(from: base.utf16.startIndex, to: upperBound.samePosition(in: base.utf16)!) diff --git a/MuseionTests/ImportExternalTests.swift b/MuseionTests/ImportExternalTests.swift index 96ae843..45bf022 100644 --- a/MuseionTests/ImportExternalTests.swift +++ b/MuseionTests/ImportExternalTests.swift @@ -88,7 +88,7 @@ struct ImportExternalTests { // A UTF-16 encoded file: String(contentsOf: .utf8) fails → nil. let ext = FileManager.default.temporaryDirectory .appendingPathComponent("museion-ext-\(UUID().uuidString)-utf16.md") - let data = "# Title\n\nBody.".data(using: .utf16)! + let data = try #require("# Title\n\nBody.".data(using: .utf16)) try data.write(to: ext) defer { try? FileManager.default.removeItem(at: ext) }