mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-04-25 12:24:47 +02:00
"opening and editing"
This commit is contained in:
parent
3839719154
commit
c965333756
@ -193,8 +193,8 @@ func genericFileOpen(g *gocui.Gui, v *gocui.View, open func(*gocui.Gui, string)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
if output, err := open(g, file.Name); err != nil {
|
||||
return createErrorPanel(g, output)
|
||||
if _, err := open(g, file.Name); err != nil {
|
||||
return createErrorPanel(g, err.Error())
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -19,6 +19,9 @@ import (
|
||||
var (
|
||||
// ErrNoCheckedOutBranch : When we have no checked out branch
|
||||
ErrNoCheckedOutBranch = errors.New("No currently checked out branch")
|
||||
|
||||
// ErrNoOpenCommand : When we don't know which command to use to open a file
|
||||
ErrNoOpenCommand = errors.New("Unsure what command to use to open this file")
|
||||
)
|
||||
|
||||
// GitFile : A staged/unstaged file
|
||||
@ -278,8 +281,26 @@ func sublimeOpenFile(g *gocui.Gui, filename string) (string, error) {
|
||||
}
|
||||
|
||||
func openFile(g *gocui.Gui, filename string) (string, error) {
|
||||
cmdName, cmdTrail := getOpenCommand()
|
||||
return runCommand(cmdName + " " + filename + " " + cmdTrail) // TODO: find out why finder is being opened here
|
||||
cmdName, cmdTrail, err := getOpenCommand()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return runCommand(cmdName + " " + filename + cmdTrail)
|
||||
}
|
||||
|
||||
func getOpenCommand() (string, string, error) {
|
||||
//NextStep open equivalents: xdg-open (linux), cygstart (cygwin), open (OSX)
|
||||
trailMap := map[string]string{
|
||||
"xdg-open": " &>/dev/null &",
|
||||
"cygstart": "",
|
||||
"open": "",
|
||||
}
|
||||
for name, trail := range trailMap {
|
||||
if out, _ := runCommand("which " + name); out != "exit status 1" {
|
||||
return name, trail, nil
|
||||
}
|
||||
}
|
||||
return "", "", ErrNoOpenCommand
|
||||
}
|
||||
|
||||
func gitAddPatch(g *gocui.Gui, filename string) {
|
||||
@ -299,20 +320,6 @@ func editFile(g *gocui.Gui, filename string) (string, error) {
|
||||
return "", nil
|
||||
}
|
||||
|
||||
func getOpenCommand() (string, string) {
|
||||
//NextStep open equivalents: xdg-open (linux), cygstart (cygwin), open (OSX)
|
||||
trailMap := map[string]string{
|
||||
"xdg-open": "&>/dev/null &",
|
||||
"cygstart": "",
|
||||
}
|
||||
for name, trail := range trailMap {
|
||||
if out, _ := runCommand("which " + name); out != "exit status 1" {
|
||||
return name, trail
|
||||
}
|
||||
}
|
||||
return "open", ""
|
||||
}
|
||||
|
||||
func runSubProcess(g *gocui.Gui, cmdName string, commandArgs ...string) {
|
||||
subprocess = exec.Command(cmdName, commandArgs...)
|
||||
subprocess.Stdin = os.Stdin
|
||||
|
10
main.go
10
main.go
@ -19,7 +19,6 @@ var (
|
||||
ErrSubprocess = errors.New("running subprocess")
|
||||
subprocess *exec.Cmd
|
||||
startTime time.Time
|
||||
debugging bool
|
||||
|
||||
// Rev - Git Revision
|
||||
Rev string
|
||||
@ -27,9 +26,9 @@ var (
|
||||
// Version - Version number
|
||||
Version = "unversioned"
|
||||
|
||||
builddate string
|
||||
debuggingPointer = flag.Bool("debug", false, "a boolean")
|
||||
versionFlag = flag.Bool("v", false, "Print the current version")
|
||||
builddate string
|
||||
debuggingFlag = flag.Bool("debug", false, "a boolean")
|
||||
versionFlag = flag.Bool("v", false, "Print the current version")
|
||||
)
|
||||
|
||||
func homeDirectory() string {
|
||||
@ -53,7 +52,7 @@ func commandLog(objects ...interface{}) {
|
||||
}
|
||||
|
||||
func localLog(colour color.Attribute, path string, objects ...interface{}) {
|
||||
if !debugging {
|
||||
if !*debuggingFlag {
|
||||
return
|
||||
}
|
||||
f, _ := os.OpenFile(path, os.O_APPEND|os.O_WRONLY, 0644)
|
||||
@ -75,7 +74,6 @@ func navigateToRepoRootDirectory() {
|
||||
|
||||
func main() {
|
||||
startTime = time.Now()
|
||||
debugging = *debuggingPointer
|
||||
devLog("\n\n\n\n\n\n\n\n\n\n")
|
||||
flag.Parse()
|
||||
if *versionFlag {
|
||||
|
Loading…
x
Reference in New Issue
Block a user