mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-09-10 07:36:27 -04:00
Support absolute paths when detecting edit preset from EDITOR env var
This commit is contained in:
parent
df0943ad33
commit
f15f713c68
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Reference in a new issue