diff --git a/go.mod b/go.mod index 13df3e490..39f3968ea 100644 --- a/go.mod +++ b/go.mod @@ -18,7 +18,7 @@ require ( github.com/integrii/flaggy v1.4.0 github.com/jesseduffield/generics v0.0.0-20220320043834-727e535cbe68 github.com/jesseduffield/go-git/v5 v5.1.2-0.20221018185014-fdd53fef665d - github.com/jesseduffield/gocui v0.3.1-0.20230217232659-7a98151b05c3 + github.com/jesseduffield/gocui v0.3.1-0.20230219034834-06a1f1e95da5 github.com/jesseduffield/kill v0.0.0-20220618033138-bfbe04675d10 github.com/jesseduffield/lazycore v0.0.0-20221012050358-03d2e40243c5 github.com/jesseduffield/minimal/gitignore v0.3.3-0.20211018110810-9cde264e6b1e diff --git a/go.sum b/go.sum index 371f7b2a2..7b8d82222 100644 --- a/go.sum +++ b/go.sum @@ -72,8 +72,8 @@ github.com/jesseduffield/generics v0.0.0-20220320043834-727e535cbe68 h1:EQP2Tv8T github.com/jesseduffield/generics v0.0.0-20220320043834-727e535cbe68/go.mod h1:+LLj9/WUPAP8LqCchs7P+7X0R98HiFujVFANdNaxhGk= github.com/jesseduffield/go-git/v5 v5.1.2-0.20221018185014-fdd53fef665d h1:bO+OmbreIv91rCe8NmscRwhFSqkDJtzWCPV4Y+SQuXE= github.com/jesseduffield/go-git/v5 v5.1.2-0.20221018185014-fdd53fef665d/go.mod h1:nGNEErzf+NRznT+N2SWqmHnDnF9aLgANB1CUNEan09o= -github.com/jesseduffield/gocui v0.3.1-0.20230217232659-7a98151b05c3 h1:dNhaHQ5aK/j0zSUM7lqCxusQXVw84GyEpJ2xOm9LdUc= -github.com/jesseduffield/gocui v0.3.1-0.20230217232659-7a98151b05c3/go.mod h1:znJuCDnF2Ph40YZSlBwdX/4GEofnIoWLGdT4mK5zRAU= +github.com/jesseduffield/gocui v0.3.1-0.20230219034834-06a1f1e95da5 h1:6mrOZa9I1bol14HhVK0tl4w9xvvGKLWPmShPRey1Lxg= +github.com/jesseduffield/gocui v0.3.1-0.20230219034834-06a1f1e95da5/go.mod h1:znJuCDnF2Ph40YZSlBwdX/4GEofnIoWLGdT4mK5zRAU= github.com/jesseduffield/kill v0.0.0-20220618033138-bfbe04675d10 h1:jmpr7KpX2+2GRiE91zTgfq49QvgiqB0nbmlwZ8UnOx0= github.com/jesseduffield/kill v0.0.0-20220618033138-bfbe04675d10/go.mod h1:aA97kHeNA+sj2Hbki0pvLslmE4CbDyhBeSSTUUnOuVo= github.com/jesseduffield/lazycore v0.0.0-20221012050358-03d2e40243c5 h1:CDuQmfOjAtb1Gms6a1p5L2P8RhbLUq5t8aL7PiQd2uY= diff --git a/pkg/gui/gui_driver.go b/pkg/gui/gui_driver.go index cf1e3bbb4..d9735c2fe 100644 --- a/pkg/gui/gui_driver.go +++ b/pkg/gui/gui_driver.go @@ -50,10 +50,18 @@ func (self *GuiDriver) CurrentContext() types.Context { } func (self *GuiDriver) Fail(message string) { + currentView := self.gui.g.CurrentView() + fullMessage := fmt.Sprintf( + "%s\nFinal Lazygit state:\n%s\nUpon failure, focused view was '%s'.\nLog:\n%s", message, + self.gui.g.Snapshot(), + currentView.Name(), + strings.Join(self.gui.CmdLog, "\n"), + ) + self.gui.g.Close() // need to give the gui time to close time.Sleep(time.Millisecond * 100) - panic(fmt.Sprintf("%s\nLog:\n%s", message, strings.Join(self.gui.CmdLog, "\n"))) + panic(fullMessage) } // logs to the normal place that you log to i.e. viewable with `lazygit --logs` diff --git a/vendor/github.com/jesseduffield/gocui/gui.go b/vendor/github.com/jesseduffield/gocui/gui.go index 3953c343b..f18e7fb38 100644 --- a/vendor/github.com/jesseduffield/gocui/gui.go +++ b/vendor/github.com/jesseduffield/gocui/gui.go @@ -1555,3 +1555,30 @@ func (g *Gui) matchView(v *View, kb *keybinding) bool { } return true } + +// returns a string representation of the current state of the gui, character-for-character +func (g *Gui) Snapshot() string { + if g.screen == nil { + return "" + } + + width, height := g.screen.Size() + + builder := &strings.Builder{} + + for y := 0; y < height; y++ { + for x := 0; x < width; x++ { + char, _, _, charWidth := g.screen.GetContent(x, y) + if charWidth == 0 { + continue + } + builder.WriteRune(char) + if charWidth > 1 { + x += charWidth - 1 + } + } + builder.WriteRune('\n') + } + + return builder.String() +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 4cc7f1c14..0f2fbc274 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -172,7 +172,7 @@ github.com/jesseduffield/go-git/v5/utils/merkletrie/filesystem github.com/jesseduffield/go-git/v5/utils/merkletrie/index github.com/jesseduffield/go-git/v5/utils/merkletrie/internal/frame github.com/jesseduffield/go-git/v5/utils/merkletrie/noder -# github.com/jesseduffield/gocui v0.3.1-0.20230217232659-7a98151b05c3 +# github.com/jesseduffield/gocui v0.3.1-0.20230219034834-06a1f1e95da5 ## explicit; go 1.12 github.com/jesseduffield/gocui # github.com/jesseduffield/kill v0.0.0-20220618033138-bfbe04675d10