git/intake/main

fix: the help overlay missed the keys added after it

The overlay is the one place that says what the keys are, and it was written
before 'D' for discarding an album's saved edits existed. It is now offered
on the review screen, but only when there is something to discard.
diff --git a/internal/tui/tui.go b/internal/tui/tui.go
index 4d14175..8659a31 100644
--- a/internal/tui/tui.go
+++ b/internal/tui/tui.go
@@ -1153,16 +1153,20 @@ func (m Module) helpKeys() []helpKey {
{"q", "quit"},
}
}
- return []helpKey{
+ keys := []helpKey{
{"↑↓ / k j", "scroll"},
{"pgup / pgdown", "scroll a page"},
{"g / home", "top"},
{"G", "bottom"},
{"enter", "continue"},
{"e", "edit album"},
- {"esc", "back"},
- {"q", "quit"},
}
+ // Only offered when there is something to discard: an album whose saved
+ // edits were applied when it was opened.
+ if m.restored {
+ keys = append(keys, helpKey{"D", "discard the edits saved for this album"})
+ }
+ return append(keys, helpKey{"esc", "back"}, helpKey{"q", "quit"})
case ScreenCoverPicker:
return []helpKey{
{"↑↓ / k j", "choose"},
diff --git a/internal/tui/tui_test.go b/internal/tui/tui_test.go
index 07e0a09..327bb71 100644
--- a/internal/tui/tui_test.go
+++ b/internal/tui/tui_test.go
@@ -1201,3 +1201,27 @@ func TestSavedEditsAreDroppedAfterFiling(t *testing.T) {
t.Error("the saved sheet outlived the filing")
}
}
+
+// The overlay is the one place that says what the keys are, so a key added after
+// it has to appear there or the overlay is quietly wrong.
+func TestHelpKnowsAboutDiscardingSavedEdits(t *testing.T) {
+ m := testModule(120, 40)
+ m.pl = readyPlan()
+ m.screen, m.step = ScreenReview, StepMetadata
+
+ for _, k := range m.helpKeys() {
+ if k.key == "D" {
+ t.Fatal("'D' is offered before there is anything to discard")
+ }
+ }
+ m.restored = true
+ found := false
+ for _, k := range m.helpKeys() {
+ if k.key == "D" {
+ found = true
+ }
+ }
+ if !found {
+ t.Error("the help overlay does not mention 'D' when saved edits were restored")
+ }
+}