From 209155dc431cf70d9c8dba20625bab7e3b1a5085 Mon Sep 17 00:00:00 2001 From: Christian Cleberg Date: Wed, 1 Apr 2026 14:04:27 -0500 Subject: Fix several bugs ahead of 2.6.1 FileTreeView: when wrap is OFF, activate an explicit width constraint on the code container derived from the widest line, giving the horizontal scroll view a defined content size. Previously the constraint was deactivated with nothing to replace it, making horizontal scrolling unreliable. Also set horizontalScrollView.isScrollEnabled = !wrapLines to prevent gesture conflicts when wrap is ON. InboxView: remove the unnecessary loadThreads() network call fired after markAllThreadsRead(). The threads array is already updated optimistically and read state is persisted via InboxReadStateStore, so the refetch was redundant and caused a brief loading flash. HomeView: add scenePhase onChange handler to refresh dashboard data when the app returns to the foreground, matching the existing pattern in InboxView. DiffView: wrap DiffBlockView content in a horizontal ScrollView so long diff lines are readable. Switch inner VStack to LazyVStack for better performance on large diffs. SettingsView: replace direct UserDefaults access in behaviorSection with @AppStorage, consistent with the rest of the app. --- Hutch/Views/Repositories/FileTreeView.swift | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'Hutch/Views/Repositories/FileTreeView.swift') diff --git a/Hutch/Views/Repositories/FileTreeView.swift b/Hutch/Views/Repositories/FileTreeView.swift index 8bedb73..adacb2e 100644 --- a/Hutch/Views/Repositories/FileTreeView.swift +++ b/Hutch/Views/Repositories/FileTreeView.swift @@ -441,6 +441,7 @@ private final class CodeFileUIView: UIView { private let codeStackView = UIStackView() private var codeContainerWidthConstraint: NSLayoutConstraint? + private var codeContainerExplicitWidthConstraint: NSLayoutConstraint? private var gutterWidthConstraint: NSLayoutConstraint? private var rows: [LineRow] = [] @@ -524,6 +525,7 @@ private final class CodeFileUIView: UIView { codeContainerView.addSubview(codeStackView) codeContainerWidthConstraint = codeContainerView.widthAnchor.constraint(equalTo: horizontalScrollView.frameLayoutGuide.widthAnchor) + codeContainerExplicitWidthConstraint = codeContainerView.widthAnchor.constraint(equalToConstant: 0) gutterWidthConstraint = gutterContainerView.widthAnchor.constraint(equalToConstant: 0) NSLayoutConstraint.activate([ @@ -627,12 +629,14 @@ private final class CodeFileUIView: UIView { private func updateWrapConfiguration(resetHorizontalOffset: Bool) { horizontalScrollView.alwaysBounceHorizontal = !wrapLines - horizontalScrollView.isScrollEnabled = true + horizontalScrollView.isScrollEnabled = !wrapLines if wrapLines { codeContainerWidthConstraint?.isActive = true + codeContainerExplicitWidthConstraint?.isActive = false } else { codeContainerWidthConstraint?.isActive = false + codeContainerExplicitWidthConstraint?.isActive = true } for row in rows { @@ -664,6 +668,18 @@ private final class CodeFileUIView: UIView { row.codeHeightConstraint.constant = rowHeight } + if wrapLines { + codeContainerExplicitWidthConstraint?.constant = 0 + } else { + let maxLineWidth = rows.reduce(CGFloat(0)) { partialResult, row in + let measuredWidth = row.codeLabel.sizeThatFits( + CGSize(width: CGFloat.greatestFiniteMagnitude, height: CGFloat.greatestFiniteMagnitude) + ).width + return max(partialResult, ceil(measuredWidth)) + } + codeContainerExplicitWidthConstraint?.constant = max(maxLineWidth, availableWidth) + } + needsLineLayoutUpdate = false } -- cgit v1.2.3