krz/orgstar

A native macOS editor for org-mode files. editor org-mode swift

Commit 9559066b0e

9559066b0e7e9c77caad36564df90f108363bd34

parent: 5e78f0d110

Verified · cmc

cmc <hello@cleberg.net> · 2026-10-08 03:58 UTC

Keep the clock report's Code column title

The report matches an existing Emacs report whose heading column is titled Code.

Layout: unified · split

Sources/OrgCore/Commands/ClockReport.swift +3 −2
@@ -71,7 +71,8 @@ public enum ClockReport {
71 } 71 }
72 72
73 /// An Org table of clocked time per date and heading between `start` and `end` 73 /// An Org table of clocked time per date and heading between `start` and `end`
74 /// (inclusive, `YYYY-MM-DD`), with a total after each ISO week. 74 /// (inclusive, `YYYY-MM-DD`), with a total after each ISO week. The heading column is
75 /// titled Code, for headings named by charge code.
75 public static func timeReport(_ entries: [Entry], start: String? = nil, end: String? = nil) -> String { 76 public static func timeReport(_ entries: [Entry], start: String? = nil, end: String? = nil) -> String {
76 var totals: [String: [String: Int]] = [:] 77 var totals: [String: [String: Int]] = [:]
77 for entry in entries { 78 for entry in entries {
@@ -89,7 +90,7 @@ public enum ClockReport {
89 let dashes7 = String(repeating: "-", count: 7) 90 let dashes7 = String(repeating: "-", count: 7)
90 let rule: String = "|" + dashes14 + "+" + dashes47 + "+" + dashes7 + "|\n" 91 let rule: String = "|" + dashes14 + "+" + dashes47 + "+" + dashes7 + "|\n"
91 func row(_ a: String, _ b: String, _ c: String) -> String { "| \(pad(a, 12)) | \(pad(b, 45)) | \(padLeft(c, 5)) |\n" } 92 func row(_ a: String, _ b: String, _ c: String) -> String { "| \(pad(a, 12)) | \(pad(b, 45)) | \(padLeft(c, 5)) |\n" }
92 var out = "#+title: Time Report\n\n" + row("Date", "Heading", "Hours") + rule 93 var out = "#+title: Time Report\n\n" + row("Date", "Code", "Hours") + rule
93 var currentWeek: String? 94 var currentWeek: String?
94 var weekMinutes = 0 95 var weekMinutes = 0
95 for (date, heading) in keys { 96 for (date, heading) in keys {
Tests/OrgCoreTests/ClockTests.swift −2
@@ -133,9 +133,7 @@ struct ClockReportTests {
133 for text in texts { 133 for text in texts {
134 for (start, end) in [(nil, nil), ("2026-02-18", nil), (nil, "2026-02-20"), ("2026-02-17", "2026-02-17")] as [(String?, String?)] { 134 for (start, end) in [(nil, nil), ("2026-02-18", nil), (nil, "2026-02-20"), ("2026-02-17", "2026-02-17")] as [(String?, String?)] {
135 let ours = ClockReport.timeReport(ClockReport.entries(text), start: start, end: end) 135 let ours = ClockReport.timeReport(ClockReport.entries(text), start: start, end: end)
136 // The config titles the heading column "Code".
137 let theirs = try Self.emacsReport(text, start: start, end: end) 136 let theirs = try Self.emacsReport(text, start: start, end: end)
138 .replacingOccurrences(of: "| Code |", with: "| Heading |")
139 #expect(ours == theirs, "\(start ?? "-")..\(end ?? "-")\nours:\n\(ours)\ntheirs:\n\(theirs)") 137 #expect(ours == theirs, "\(start ?? "-")..\(end ?? "-")\nours:\n\(ours)\ntheirs:\n\(theirs)")
140 } 138 }
141 } 139 }