termui: add the previous title in the template when editing

Michael Muré created

Change summary

input/input.go   | 7 ++++---
termui/termui.go | 2 +-
2 files changed, 5 insertions(+), 4 deletions(-)

Detailed changes

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

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