From 1341feeff9ffb05197586aa1cb2597424183575b Mon Sep 17 00:00:00 2001 From: Ian Gulliver Date: Fri, 23 Oct 2026 14:11:16 -0700 Subject: [PATCH] Wrap long lines in the Changes view --- mac/Sources/Byre/Changes.swift | 50 ++++++++++++++-------------------- 1 file changed, 20 insertions(+), 30 deletions(-) diff --git a/mac/Sources/Byre/Changes.swift b/mac/Sources/Byre/Changes.swift index 539613b..34ced26 100644 --- a/mac/Sources/Byre/Changes.swift +++ b/mac/Sources/Byre/Changes.swift @@ -605,40 +605,29 @@ struct DiffLines: View { let rows: [DiffRow] var taskId: String? @Environment(Store.self) private var store - @ViewState private var width: CGFloat = 0 var body: some View { - ScrollView(.horizontal) { - StretchColumn(minWidth: width) { - ForEach(Array(rows.enumerated()), id: \.offset) { _, row in - if let taskId, let anchor = row.anchor, let drafts = store.drafts { - let comment = drafts.lineComment(taskId, anchor) - DiffLineRow(row: row, mark: comment != nil, hoverable: true) - .simultaneousGesture(TapGesture().onEnded { - drafts.toggleLineComment(taskId, anchor, ready: lineCommentReady(store.images, taskId)) - }) - if comment != nil { - LineCommentBox(drafts: drafts, taskId: taskId, anchor: anchor) - .frame(width: max(0, width - 20)) - .padding(.horizontal, 10) - .padding(.vertical, 4) - .frame(maxWidth: .infinity, alignment: .leading) - } - } else { - DiffLineRow(row: row, mark: row.mark, hoverable: false) + VStack(alignment: .leading, spacing: 0) { + ForEach(Array(rows.enumerated()), id: \.offset) { _, row in + if let taskId, let anchor = row.anchor, let drafts = store.drafts { + let comment = drafts.lineComment(taskId, anchor) + DiffLineRow(row: row, mark: comment != nil, hoverable: true) + .simultaneousGesture(TapGesture().onEnded { + drafts.toggleLineComment(taskId, anchor, ready: lineCommentReady(store.images, taskId)) + }) + if comment != nil { + LineCommentBox(drafts: drafts, taskId: taskId, anchor: anchor) + .padding(.horizontal, 10) + .padding(.vertical, 4) } + } else { + DiffLineRow(row: row, mark: row.mark, hoverable: false) } } - .font(Fonts.font(11, mono: true)) - .padding(.vertical, 4) - .textSelection(.enabled) - } - .scrollBounceBehavior(.basedOnSize) - .onGeometryChange(for: CGFloat.self) { g in - g.size.width - } action: { w in - width = w } + .font(Fonts.font(11, mono: true)) + .padding(.vertical, 4) + .textSelection(.enabled) } } @@ -649,17 +638,18 @@ private struct DiffLineRow: View { @ViewState private var hover = false var body: some View { - HStack(spacing: 0) { + HStack(alignment: .firstTextBaseline, spacing: 0) { if let n = row.lineno { Text(n) .foregroundStyle(Palette.muted) .frame(minWidth: 30, alignment: .trailing) .padding(.trailing, 8) + .fixedSize() } Text(verbatim: row.text.isEmpty ? " " : row.text) .foregroundStyle(row.kind.color) + .fixedSize(horizontal: false, vertical: true) } - .fixedSize() .padding(.horizontal, 10) .frame(maxWidth: .infinity, alignment: .leading) .background(row.kind.background)