text editor selection: follow unix defacto standards #356
@ -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)
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user