Переглянути джерело

fix(config): fall back to vim when $EDITOR is unset

- Guard against empty editor in CreateEditorCommand to prevent
  executing the config file path as a command
- Default to vim when editor is "default" and $EDITOR is not set

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
claude 1 місяць тому
батько
коміт
fdbd5967c1
2 змінених файлів з 8 додано та 1 видалено
  1. 5 1
      internal/config/config.go
  2. 3 0
      internal/config/editor_unix.go

+ 5 - 1
internal/config/config.go

@@ -170,7 +170,11 @@ func Load(path string) (*Config, error) {
 
 func applyDefaults(cfg *Config) {
 	if cfg.Editor == "default" {
-		cfg.Editor = os.Getenv("EDITOR")
+		if editor := os.Getenv("EDITOR"); editor != "" {
+			cfg.Editor = editor
+		} else {
+			cfg.Editor = "vim"
+		}
 	}
 
 	if cfg.Status == "default" {

+ 3 - 0
internal/config/editor_unix.go

@@ -7,5 +7,8 @@ import (
 )
 
 func (cfg *Config) CreateEditorCommand(path string) *exec.Cmd {
+	if cfg.Editor == "" {
+		return nil
+	}
 	return exec.Command("sh", "-c", cfg.Editor+" \"$@\"", cfg.Editor, path)
 }