From b9708c9f8850352d18ef4d10c285698be882f838 Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Wed, 19 Sep 2018 20:36:40 +1000 Subject: [PATCH 1/6] fix issues with commit message panel losing focus --- pkg/gui/commit_message_panel.go | 4 ++++ pkg/gui/view_helpers.go | 9 ++++++++- pkg/utils/utils.go | 10 ++++++++++ pkg/utils/utils_test.go | 35 +++++++++++++++++++++++++++++++++ 4 files changed, 57 insertions(+), 1 deletion(-) diff --git a/pkg/gui/commit_message_panel.go b/pkg/gui/commit_message_panel.go index e23c47da0..74e02be90 100644 --- a/pkg/gui/commit_message_panel.go +++ b/pkg/gui/commit_message_panel.go @@ -37,6 +37,10 @@ func (gui *Gui) handleCommitClose(g *gocui.Gui, v *gocui.View) error { } func (gui *Gui) handleCommitFocused(g *gocui.Gui, v *gocui.View) error { + if _, err := g.SetViewOnTop("commitMessage"); err != nil { + return err + } + message := gui.Tr.TemplateLocalize( "CloseConfirm", Teml{ diff --git a/pkg/gui/view_helpers.go b/pkg/gui/view_helpers.go index 5178bd4d9..96a77f3d6 100644 --- a/pkg/gui/view_helpers.go +++ b/pkg/gui/view_helpers.go @@ -133,8 +133,15 @@ func (gui *Gui) switchFocus(g *gocui.Gui, oldView, newView *gocui.View) error { }, ) gui.Log.Info(message) - gui.State.PreviousView = oldView.Name() + + // second class panels should never have focus restored to them because + // once they lose focus they are effectively 'destroyed' + secondClassPanels := []string{"confirmation", "menu"} + if !utils.IncludesString(secondClassPanels, oldView.Name()) { + gui.State.PreviousView = oldView.Name() + } } + newView.Highlight = true message := gui.Tr.TemplateLocalize( "newFocusedViewIs", diff --git a/pkg/utils/utils.go b/pkg/utils/utils.go index aef653c50..8e481b3a4 100644 --- a/pkg/utils/utils.go +++ b/pkg/utils/utils.go @@ -204,3 +204,13 @@ func getDisplayStringArrays(displayables []Displayable) [][]string { } return stringArrays } + +// IncludesString if the list contains the string +func IncludesString(list []string, a string) bool { + for _, b := range list { + if b == a { + return true + } + } + return false +} diff --git a/pkg/utils/utils_test.go b/pkg/utils/utils_test.go index 918031512..21e1d5031 100644 --- a/pkg/utils/utils_test.go +++ b/pkg/utils/utils_test.go @@ -376,3 +376,38 @@ func TestMin(t *testing.T) { assert.EqualValues(t, s.expected, Min(s.a, s.b)) } } + +func TestIncludesString(t *testing.T) { + type scenario struct { + list []string + element string + expected bool + } + + scenarios := []scenario{ + { + []string{"a", "b"}, + "a", + true, + }, + { + []string{"a", "b"}, + "c", + false, + }, + { + []string{"a", "b"}, + "", + false, + }, + { + []string{""}, + "", + true, + }, + } + + for _, s := range scenarios { + assert.EqualValues(t, s.expected, IncludesString(s.list, s.element)) + } +} From 70ee4faf15a15ebb8ae28db70fa52dd2e33f6c1e Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Thu, 20 Sep 2018 09:48:56 +1000 Subject: [PATCH 2/6] add removeAll to git --- pkg/commands/git.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/commands/git.go b/pkg/commands/git.go index c37ca9b47..4163b46e9 100644 --- a/pkg/commands/git.go +++ b/pkg/commands/git.go @@ -101,6 +101,7 @@ func NewGitCommand(log *logrus.Entry, osCommand *OSCommand, tr *i18n.Localizer) Repo: repo, getGlobalGitConfig: gitconfig.Global, getLocalGitConfig: gitconfig.Local, + removeFile: os.RemoveAll, }, nil } From 227067fdd11669bd4f991af5d139659df7fc5921 Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Sat, 22 Sep 2018 13:44:48 +1000 Subject: [PATCH 3/6] use lineheight rather than buffer length --- Gopkg.lock | 4 ++-- go.mod | 2 +- vendor/github.com/jesseduffield/gocui/view.go | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Gopkg.lock b/Gopkg.lock index 540b26052..4b84d6537 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -189,11 +189,11 @@ [[projects]] branch = "master" - digest = "1:d6df25dee1274e63c25f84c257bc504359f975dedb791eec7a5b51992146bb76" + digest = "1:66bb9b4a5abb704642fccba52a84a7f7feef2d9623f87b700e52a6695044723f" name = "github.com/jesseduffield/gocui" packages = ["."] pruneopts = "NUT" - revision = "4fca348422d8b6136e801b222858204a35ee369a" + revision = "03e26ff3f1de2c1bc2205113c3aba661312eee00" [[projects]] branch = "master" diff --git a/go.mod b/go.mod index 61692f46e..bfa4f7cf4 100644 --- a/go.mod +++ b/go.mod @@ -18,7 +18,7 @@ require ( github.com/heroku/rollrus v0.0.0-20180515183152-fc0cef2ff331 github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 github.com/jesseduffield/go-getter v0.0.0-20180822080847-906e15686e63 - github.com/jesseduffield/gocui v0.0.0-20180919095827-4fca348422d8 + github.com/jesseduffield/gocui v0.0.0-20180921065632-03e26ff3f1de github.com/jesseduffield/termbox-go v0.0.0-20180919093808-1e272ff78dcb github.com/jmespath/go-jmespath v0.0.0-20160202185014-0b12d6b521d8 github.com/kardianos/osext v0.0.0-20170510131534-ae77be60afb1 diff --git a/vendor/github.com/jesseduffield/gocui/view.go b/vendor/github.com/jesseduffield/gocui/view.go index 46b86ec2a..939d1bdfa 100644 --- a/vendor/github.com/jesseduffield/gocui/view.go +++ b/vendor/github.com/jesseduffield/gocui/view.go @@ -447,8 +447,8 @@ func (v *View) ViewBufferLines() []string { return lines } -func (v *View) ViewLinesHeight() int { - return len(v.viewLines) +func (v *View) LinesHeight() int { + return len(v.lines) } // ViewBuffer returns a string with the contents of the view's buffer that is From 619c28ce56c50b6472d75158211f4bc6141b1bfd Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Sat, 22 Sep 2018 13:44:48 +1000 Subject: [PATCH 4/6] use lineheight rather than buffer length --- Gopkg.lock | 4 ++-- go.mod | 2 +- pkg/gui/view_helpers.go | 4 ++-- vendor/github.com/jesseduffield/gocui/view.go | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Gopkg.lock b/Gopkg.lock index 540b26052..4b84d6537 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -189,11 +189,11 @@ [[projects]] branch = "master" - digest = "1:d6df25dee1274e63c25f84c257bc504359f975dedb791eec7a5b51992146bb76" + digest = "1:66bb9b4a5abb704642fccba52a84a7f7feef2d9623f87b700e52a6695044723f" name = "github.com/jesseduffield/gocui" packages = ["."] pruneopts = "NUT" - revision = "4fca348422d8b6136e801b222858204a35ee369a" + revision = "03e26ff3f1de2c1bc2205113c3aba661312eee00" [[projects]] branch = "master" diff --git a/go.mod b/go.mod index 61692f46e..bfa4f7cf4 100644 --- a/go.mod +++ b/go.mod @@ -18,7 +18,7 @@ require ( github.com/heroku/rollrus v0.0.0-20180515183152-fc0cef2ff331 github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 github.com/jesseduffield/go-getter v0.0.0-20180822080847-906e15686e63 - github.com/jesseduffield/gocui v0.0.0-20180919095827-4fca348422d8 + github.com/jesseduffield/gocui v0.0.0-20180921065632-03e26ff3f1de github.com/jesseduffield/termbox-go v0.0.0-20180919093808-1e272ff78dcb github.com/jmespath/go-jmespath v0.0.0-20160202185014-0b12d6b521d8 github.com/kardianos/osext v0.0.0-20170510131534-ae77be60afb1 diff --git a/pkg/gui/view_helpers.go b/pkg/gui/view_helpers.go index 5178bd4d9..e9362c41f 100644 --- a/pkg/gui/view_helpers.go +++ b/pkg/gui/view_helpers.go @@ -183,7 +183,7 @@ func (gui *Gui) cursorDown(g *gocui.Gui, v *gocui.View) error { } cx, cy := v.Cursor() ox, oy := v.Origin() - ly := len(v.BufferLines()) - 1 + ly := v.LinesHeight() - 1 _, height := v.Size() maxY := height - 1 @@ -219,7 +219,7 @@ func (gui *Gui) correctCursor(v *gocui.View) error { ox, oy := v.Origin() _, height := v.Size() maxY := height - 1 - ly := len(v.BufferLines()) - 1 + ly := v.LinesHeight() - 1 if oy+cy <= ly { return nil } diff --git a/vendor/github.com/jesseduffield/gocui/view.go b/vendor/github.com/jesseduffield/gocui/view.go index 46b86ec2a..939d1bdfa 100644 --- a/vendor/github.com/jesseduffield/gocui/view.go +++ b/vendor/github.com/jesseduffield/gocui/view.go @@ -447,8 +447,8 @@ func (v *View) ViewBufferLines() []string { return lines } -func (v *View) ViewLinesHeight() int { - return len(v.viewLines) +func (v *View) LinesHeight() int { + return len(v.lines) } // ViewBuffer returns a string with the contents of the view's buffer that is From 4e0d0f7d75642472abc10d500989716bbd974f41 Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Sun, 23 Sep 2018 13:09:54 +1000 Subject: [PATCH 5/6] Update README.md --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 4f40e8f8e..e20de5900 100644 --- a/README.md +++ b/README.md @@ -121,6 +121,11 @@ For contributor discussion about things not better discussed here in the repo, j [![Slack](/docs/resources/slack_rgb.png)](https://join.slack.com/t/lazygit/shared_invite/enQtNDE3MjIwNTYyMDA0LTM3Yjk3NzdiYzhhNTA1YjM4Y2M4MWNmNDBkOTI0YTE4YjQ1ZmI2YWRhZTgwNjg2YzhhYjg3NDBlMmQyMTI5N2M) +## Donate +If you would like to support the development of lazygit, please donate + +[![Donate](https://d1iczxrky3cnb2.cloudfront.net/button-medium-blue.png)](https://donorbox.org/lazygit) + ## Work in progress This is still a work in progress so there's still bugs to iron out and as this is my first project in Go the code could no doubt use an increase in quality, From 3d751c03fe34ac8547dfd0e39d8964129ec4c095 Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Sun, 23 Sep 2018 14:13:10 +1000 Subject: [PATCH 6/6] add donation link to status panel --- pkg/gui/status_panel.go | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/pkg/gui/status_panel.go b/pkg/gui/status_panel.go index 6948e9678..89b3e997e 100644 --- a/pkg/gui/status_panel.go +++ b/pkg/gui/status_panel.go @@ -2,6 +2,7 @@ package gui import ( "fmt" + "strings" "github.com/fatih/color" "github.com/jesseduffield/gocui" @@ -51,14 +52,16 @@ func (gui *Gui) handleCheckForUpdate(g *gocui.Gui, v *gocui.View) error { } func (gui *Gui) handleStatusSelect(g *gocui.Gui, v *gocui.View) error { - dashboardString := fmt.Sprintf( - "%s\n\n%s\n\n%s\n\n%s\n\n%s", - lazygitTitle(), - "Keybindings: https://github.com/jesseduffield/lazygit/blob/master/docs/Keybindings.md", - "Config Options: https://github.com/jesseduffield/lazygit/blob/master/docs/Config.md", - "Tutorial: https://www.youtube.com/watch?v=VDXvbHZYeKY", - "Raise an Issue: https://github.com/jesseduffield/lazygit/issues", - ) + dashboardString := strings.Join( + []string{ + lazygitTitle(), + "Copyright (c) 2018 Jesse Duffield", + "Keybindings: https://github.com/jesseduffield/lazygit/blob/master/docs/Keybindings.md", + "Config Options: https://github.com/jesseduffield/lazygit/blob/master/docs/Config.md", + "Tutorial: https://www.youtube.com/watch?v=VDXvbHZYeKY", + "Raise an Issue: https://github.com/jesseduffield/lazygit/issues", + "Buy Jesse a coffee: https://donorbox.org/lazygit", + }, "\n\n") if err := gui.renderString(g, "main", dashboardString); err != nil { return err