Wrap long lines in the Changes view
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user