Skip to content

Commit

Permalink
Honor some editor env vars before falling back to notepad on Windows (#…
Browse files Browse the repository at this point in the history
…480)

feat: Fallback to notepad on Windows

Instead of unconditionally using notepad

Signed-off-by: Josh Soref <[email protected]>

Signed-off-by: Josh Soref <[email protected]>
Co-authored-by: Sergiu Ghitea <[email protected]>
  • Loading branch information
jsoref and sergiught authored Aug 19, 2022
1 parent 05bc8d8 commit 369bdb6
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions internal/prompt/editor.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,14 @@ func (p *editorPrompt) captureInput(contents []byte, pattern string, infoFn func
// getDefaultEditor is taken from https://github.com/cli/cli/blob/trunk/pkg/surveyext/editor_manual.go
// and tries to infer the editor from different heuristics.
func getDefaultEditor() string {
if runtime.GOOS == "windows" {
return "notepad"
} else if g := os.Getenv("GIT_EDITOR"); g != "" {
if g := os.Getenv("GIT_EDITOR"); g != "" {
return g
} else if v := os.Getenv("VISUAL"); v != "" {
return v
} else if e := os.Getenv("EDITOR"); e != "" {
return e
} else if runtime.GOOS == "windows" {
return "notepad"
}

return defaultEditor
Expand Down

0 comments on commit 369bdb6

Please sign in to comment.