diff --git a/command/editor.go b/command/editor.go index 27f019a00..6ab141e9a 100644 --- a/command/editor.go +++ b/command/editor.go @@ -8,6 +8,7 @@ import ( "io/ioutil" "os" "os/exec" + "path/filepath" "runtime" "github.com/AlecAivazis/survey/v2" @@ -46,18 +47,28 @@ var EditorQuestionTemplate = ` {{- else }} {{- if and .Help (not .ShowHelp)}}{{color "cyan"}}[{{ .Config.HelpInput }} for help]{{color "reset"}} {{end}} {{- if and .Default (not .HideDefault)}}{{color "white"}}({{.Default}}) {{color "reset"}}{{end}} - {{- color "cyan"}}[e: launch editor][enter: skip for now] {{color "reset"}} + {{- color "cyan"}}[e: launch {{ .EditorName }}][enter: skip for now] {{color "reset"}} {{- end}}` +type EditorTemplateData struct { + survey.Editor + EditorName string + Answer string + ShowAnswer bool + ShowHelp bool + Config *survey.PromptConfig +} + // this is not being called in the embedding case and isn't consulted in the alias case because of // the incomplete overriding. func (e *ghEditor) prompt(initialValue string, config *survey.PromptConfig) (interface{}, error) { // render the template err := e.Render( EditorQuestionTemplate, - survey.EditorTemplateData{ - Editor: *e.Editor, - Config: config, + EditorTemplateData{ + Editor: *e.Editor, + EditorName: filepath.Base(editor), + Config: config, }, ) if err != nil { @@ -93,10 +104,11 @@ func (e *ghEditor) prompt(initialValue string, config *survey.PromptConfig) (int if string(r) == config.HelpInput && e.Help != "" { err = e.Render( EditorQuestionTemplate, - survey.EditorTemplateData{ - Editor: *e.Editor, - ShowHelp: true, - Config: config, + EditorTemplateData{ + Editor: *e.Editor, + EditorName: filepath.Base(editor), + ShowHelp: true, + Config: config, }, ) if err != nil { diff --git a/command/title_body_survey.go b/command/title_body_survey.go index 661236ad3..8a5252bd4 100644 --- a/command/title_body_survey.go +++ b/command/title_body_survey.go @@ -1,8 +1,6 @@ package command import ( - "fmt" - "github.com/AlecAivazis/survey/v2" "github.com/github/gh-cli/pkg/githubtemplate" "github.com/pkg/errors" @@ -99,7 +97,7 @@ func titleBodySurvey(cmd *cobra.Command, providedTitle string, providedBody stri Name: "body", Prompt: &ghEditor{ Editor: &survey.Editor{ - Message: fmt.Sprintf("Body (%s)", editor), + Message: "Body", FileName: "*.md", Default: inProgress.Body, HideDefault: true,