diff --git a/modules/interact/pull_review.go b/modules/interact/pull_review.go index 7a190ef..1052dcd 100644 --- a/modules/interact/pull_review.go +++ b/modules/interact/pull_review.go @@ -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) diff --git a/modules/task/pull_review.go b/modules/task/pull_review.go index 1cef147..ff3bd08 100644 --- a/modules/task/pull_review.go +++ b/modules/task/pull_review.go @@ -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.