diff --git a/grammar.go b/grammar.go index 9a1b658..8fbe230 100644 --- a/grammar.go +++ b/grammar.go @@ -820,15 +820,21 @@ func ProgressSubject(verb, subject string) string { return "" } suffix := getPunct(lang, "progress", "...") + if subject == "" { + return Title(g) + suffix + } return Title(g) + " " + renderWord(lang, subject) + suffix } // ActionResult returns a completion message: "File deleted" func ActionResult(verb, subject string) string { p := PastTense(verb) - if p == "" || subject == "" { + if p == "" { return "" } + if subject == "" { + return Title(p) + } return renderWordOrTitle(currentLangForGrammar(), subject) + " " + p } diff --git a/grammar_test.go b/grammar_test.go index d2418df..59dfd37 100644 --- a/grammar_test.go +++ b/grammar_test.go @@ -725,7 +725,7 @@ func TestActionResult(t *testing.T) { {"delete", "config.yaml", "Config.yaml deleted"}, {"build", "project", "Project built"}, {"", "file", ""}, - {"delete", "", ""}, + {"delete", "", "Deleted"}, } for _, tt := range tests { @@ -1070,9 +1070,15 @@ func TestCompositeHelpersRespectWordMap(t *testing.T) { if got, want := ProgressSubject("build", "go_mod"), "Building go.mod..."; got != want { t.Fatalf("ProgressSubject(%q, %q) = %q, want %q", "build", "go_mod", got, want) } + if got, want := ProgressSubject("build", ""), "Building..."; got != want { + t.Fatalf("ProgressSubject(%q, %q) = %q, want %q", "build", "", got, want) + } if got, want := ActionResult("delete", "go_mod"), "go.mod deleted"; got != want { t.Fatalf("ActionResult(%q, %q) = %q, want %q", "delete", "go_mod", got, want) } + if got, want := ActionResult("delete", ""), "Deleted"; got != want { + t.Fatalf("ActionResult(%q, %q) = %q, want %q", "delete", "", got, want) + } if got, want := ActionFailed("delete", "go_mod"), "Failed to delete go.mod"; got != want { t.Fatalf("ActionFailed(%q, %q) = %q, want %q", "delete", "go_mod", got, want) }