7d7238ba33
The file diff sat in a narrow centred column with empty space around it: cells had a fixed minWidth inside a two-axis ScrollView, and the empty/notice states were vertically centred. Now each side takes exactly half the width, content is anchored top-leading, and scrolling is vertical only, with long lines wrapping (a "Wrap lines" toggle turns that off for code, remembered across launches). The tree's right column was pinned at 220pt regardless of window size; both name columns now share the space evenly and only the status column is fixed. The "only differences" checkbox became a filter with the modes worth having when reviewing a real comparison: everything, only differences, only changed files, only on the left, only on the right, only on one side. Folders survive filtering only when something inside them does, so no empty branches are left behind. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UfhDYRLTpGJSKGP1m3LVJN
55 lines
1.7 KiB
Swift
55 lines
1.7 KiB
Swift
import SwiftUI
|
|
import KotejEngine
|
|
|
|
/// What the tree shows. Reviewing a big comparison usually means looking at one
|
|
/// kind of difference at a time — what changed, what only exists on one side —
|
|
/// rather than everything at once.
|
|
enum RowFilter: String, CaseIterable, Identifiable {
|
|
/// Every row, differences or not.
|
|
case all
|
|
/// Anything that isn't identical.
|
|
case differences
|
|
/// Files present on both sides whose contents differ.
|
|
case changed
|
|
/// Present on the left only.
|
|
case orphansLeft
|
|
/// Present on the right only.
|
|
case orphansRight
|
|
/// Present on one side only, either side.
|
|
case orphans
|
|
|
|
var id: String { rawValue }
|
|
|
|
var label: LocalizedStringKey {
|
|
switch self {
|
|
case .all: return "Everything"
|
|
case .differences: return "Only differences"
|
|
case .changed: return "Only changed files"
|
|
case .orphansLeft: return "Only on the left"
|
|
case .orphansRight: return "Only on the right"
|
|
case .orphans: return "Only on one side"
|
|
}
|
|
}
|
|
|
|
func matches(_ status: DiffStatus) -> Bool {
|
|
switch self {
|
|
case .all:
|
|
return true
|
|
case .differences:
|
|
return status.isDifference
|
|
case .changed:
|
|
// Pending counts: it's undecided, not proven equal.
|
|
return status == .different || status == .pending
|
|
case .orphansLeft:
|
|
return status == .onlyLeft
|
|
case .orphansRight:
|
|
return status == .onlyRight
|
|
case .orphans:
|
|
return status == .onlyLeft || status == .onlyRight
|
|
}
|
|
}
|
|
|
|
/// True when the filter hides anything at all.
|
|
var hidesRows: Bool { self != .all }
|
|
}
|