From f15f713c689cb54faf7dc722bbfc00455884a4ab Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Thu, 30 Jul 2026 17:31:56 +0200 Subject: [PATCH] Support absolute paths when detecting edit preset from EDITOR env var --- pkg/commands/git_commands/file.go | 3 ++- pkg/commands/git_commands/file_test.go | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/pkg/commands/git_commands/file.go b/pkg/commands/git_commands/file.go index 1b5f5b2dd..00f46e821 100644 --- a/pkg/commands/git_commands/file.go +++ b/pkg/commands/git_commands/file.go @@ -2,6 +2,7 @@ package git_commands import ( "os" + "path/filepath" "strconv" "strings" @@ -93,7 +94,7 @@ func (self *FileCommands) guessDefaultEditor() string { // At this point, it might be more than just the name of the editor; // e.g. it might be "code -w" or "vim -u myvim.rc". So assume that // everything up to the first space is the editor name. - editor = strings.Split(editor, " ")[0] + editor = filepath.Base(strings.Split(editor, " ")[0]) } return editor diff --git a/pkg/commands/git_commands/file_test.go b/pkg/commands/git_commands/file_test.go index 5dd3d133c..8f91f797c 100644 --- a/pkg/commands/git_commands/file_test.go +++ b/pkg/commands/git_commands/file_test.go @@ -203,6 +203,17 @@ func TestGuessDefaultEditor(t *testing.T) { }, expectedResult: "bbedit", }, + { + gitConfigMockResponses: nil, + getenv: func(env string) string { + if env == "EDITOR" { + return "/usr/bin/nvim" + } + + return "" + }, + expectedResult: "nvim", + }, } for _, s := range scenarios {