Ensure markdown confirm prompt shows editor name

Apparently, `gh` might not actually have an editor at the time we're prompting
the user if they want to use it for markdown editing.  In the survey package,
there is a function that will handle fallback to the default editor based on
environment variables and parse it in the case the editor contains flags and
arguments for cases like Visual Studio Code.

Additionally, there are no tests for the EditorName function and the fact it
is loaded via `init` makes this difficult to test.

Co-authored-by: Kynan Ware <47394200+BagToad@users.noreply.github.com>
This commit is contained in:
Andy Feller 2025-04-10 18:11:38 -04:00 committed by Kynan Ware
parent 20ff409bfc
commit b8cd094ca8

View file

@ -234,9 +234,9 @@ func (p *accessiblePrompter) InputHostname() (string, error) {
func (p *accessiblePrompter) MarkdownEditor(prompt, defaultValue string, blankAllowed bool) (string, error) {
var result string
skipOption := "skip"
openOption := "open"
launchOption := "launch"
options := []huh.Option[string]{
huh.NewOption(fmt.Sprintf("Open Editor: %s", p.editorCmd), openOption),
huh.NewOption(fmt.Sprintf("Launch %s", surveyext.EditorName(p.editorCmd)), launchOption),
}
if blankAllowed {
options = append(options, huh.NewOption("Skip", skipOption))