From ad9e35e302fe62556414f20ba04933d9c4597681 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Mur=C3=A9?= Date: Wed, 8 Aug 2018 21:25:06 +0200 Subject: [PATCH] termui: add the previous title in the template when editing --- input/input.go | 7 ++++--- termui/termui.go | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/input/input.go b/input/input.go index 530106e290afe6bc32ee08d1f4b8812f92666cbd..2986fae5362029a14d3220eb9d9cd5639e892f3b 100644 --- a/input/input.go +++ b/input/input.go @@ -102,14 +102,15 @@ func BugCommentEditorInput(repo repository.Repo) (string, error) { return message, nil } -const bugTitleTemplate = ` +const bugTitleTemplate = `%s # Please enter the new title. Only one line will used. # Lines starting with '#' will be ignored, and an empty title aborts the operation. ` -func BugTitleEditorInput(repo repository.Repo) (string, error) { - raw, err := LaunchEditorWithTemplate(repo, messageFilename, bugTitleTemplate) +func BugTitleEditorInput(repo repository.Repo, preTitle string) (string, error) { + template := fmt.Sprintf(bugTitleTemplate, preTitle) + raw, err := LaunchEditorWithTemplate(repo, messageFilename, template) if err != nil { return "", err diff --git a/termui/termui.go b/termui/termui.go index 2e109c3f081a49b4615d92140ccc447d0645bcd8..d2585c4b956e6b9cf8d1669dd5045a889f25e477 100644 --- a/termui/termui.go +++ b/termui/termui.go @@ -215,7 +215,7 @@ func setTitleWithEditor(bug cache.BugCacher) error { ui.g.Close() ui.g = nil - title, err := input.BugTitleEditorInput(ui.cache.Repository()) + title, err := input.BugTitleEditorInput(ui.cache.Repository(), bug.Snapshot().Title) if err != nil && err != input.ErrEmptyTitle { return err