diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2023-02-19 14:49:19 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2023-02-19 15:48:09 +1100 |
commit | a51f64814ce9aab9405ad64e65645694cad5c8e3 (patch) | |
tree | 356c4a3305bc2ce1df550db6abbb39219ed5082f /vendor | |
parent | b5e325b0a487f9ae6122d8410c393f60ea40251d (diff) |
show snapshot of lazygit when test fails for easier investigation
Diffstat (limited to 'vendor')
-rw-r--r-- | vendor/github.com/jesseduffield/gocui/gui.go | 27 | ||||
-rw-r--r-- | vendor/modules.txt | 2 |
2 files changed, 28 insertions, 1 deletions
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 "<no screen rendered>" + } + + 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 |