text editor selection: follow unix defacto standards #356

Merged
6543 merged 2 commits from plgruener/tea:visual_patch into master 2021-06-21 12:08:27 +00:00
2 changed files with 7 additions and 4 deletions

View File

@ -63,7 +63,7 @@ func ReviewPull(ctx *context.TeaContext, idx int64) error {
return task.CreatePullReview(ctx, idx, state, comment, codeComments)
}
// DoDiffReview (1) fetches & saves diff in tempfile, (2) starts $EDITOR to comment on diff,
// DoDiffReview (1) fetches & saves diff in tempfile, (2) starts $VISUAL or $EDITOR to comment on diff,
// (3) parses resulting file into code comments.
func DoDiffReview(ctx *context.TeaContext, idx int64) ([]gitea.CreatePullReviewComment, error) {
tmpFile, err := task.SavePullDiff(ctx, idx)

View File

@ -107,10 +107,13 @@ func ParseDiffComments(diffFile string) ([]gitea.CreatePullReviewComment, error)
// OpenFileInEditor opens filename in a text editor, and blocks until the editor terminates.
func OpenFileInEditor(filename string) error {
editor := os.Getenv("EDITOR")
editor := os.Getenv("VISUAL")
if editor == "" {
fmt.Println("No $EDITOR env is set, defaulting to vim")
editor = "vim"
editor = os.Getenv("EDITOR")
if editor == "" {
fmt.Println("No $VISUAL or $EDITOR env is set, defaulting to vim")
editor = "vi"
}
}
// Get the full executable path for the editor.