Wrap long lines in the Changes view

This commit is contained in:
Ian Gulliver
2026-10-23 14:11:16 -07:00
parent 89c30c383e
commit 1341feeff9
+4 -14
View File
@@ -605,11 +605,9 @@ struct DiffLines: View {
let rows: [DiffRow] let rows: [DiffRow]
var taskId: String? var taskId: String?
@Environment(Store.self) private var store @Environment(Store.self) private var store
@ViewState private var width: CGFloat = 0
var body: some View { var body: some View {
ScrollView(.horizontal) { VStack(alignment: .leading, spacing: 0) {
StretchColumn(minWidth: width) {
ForEach(Array(rows.enumerated()), id: \.offset) { _, row in ForEach(Array(rows.enumerated()), id: \.offset) { _, row in
if let taskId, let anchor = row.anchor, let drafts = store.drafts { if let taskId, let anchor = row.anchor, let drafts = store.drafts {
let comment = drafts.lineComment(taskId, anchor) let comment = drafts.lineComment(taskId, anchor)
@@ -619,10 +617,8 @@ struct DiffLines: View {
}) })
if comment != nil { if comment != nil {
LineCommentBox(drafts: drafts, taskId: taskId, anchor: anchor) LineCommentBox(drafts: drafts, taskId: taskId, anchor: anchor)
.frame(width: max(0, width - 20))
.padding(.horizontal, 10) .padding(.horizontal, 10)
.padding(.vertical, 4) .padding(.vertical, 4)
.frame(maxWidth: .infinity, alignment: .leading)
} }
} else { } else {
DiffLineRow(row: row, mark: row.mark, hoverable: false) DiffLineRow(row: row, mark: row.mark, hoverable: false)
@@ -633,13 +629,6 @@ struct DiffLines: View {
.padding(.vertical, 4) .padding(.vertical, 4)
.textSelection(.enabled) .textSelection(.enabled)
} }
.scrollBounceBehavior(.basedOnSize)
.onGeometryChange(for: CGFloat.self) { g in
g.size.width
} action: { w in
width = w
}
}
} }
private struct DiffLineRow: View { private struct DiffLineRow: View {
@@ -649,17 +638,18 @@ private struct DiffLineRow: View {
@ViewState private var hover = false @ViewState private var hover = false
var body: some View { var body: some View {
HStack(spacing: 0) { HStack(alignment: .firstTextBaseline, spacing: 0) {
if let n = row.lineno { if let n = row.lineno {
Text(n) Text(n)
.foregroundStyle(Palette.muted) .foregroundStyle(Palette.muted)
.frame(minWidth: 30, alignment: .trailing) .frame(minWidth: 30, alignment: .trailing)
.padding(.trailing, 8) .padding(.trailing, 8)
.fixedSize()
} }
Text(verbatim: row.text.isEmpty ? " " : row.text) Text(verbatim: row.text.isEmpty ? " " : row.text)
.foregroundStyle(row.kind.color) .foregroundStyle(row.kind.color)
.fixedSize(horizontal: false, vertical: true)
} }
.fixedSize()
.padding(.horizontal, 10) .padding(.horizontal, 10)
.frame(maxWidth: .infinity, alignment: .leading) .frame(maxWidth: .infinity, alignment: .leading)
.background(row.kind.background) .background(row.kind.background)