summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2018-09-23 14:13:14 +1000
committerJesse Duffield <jessedduffield@gmail.com>2018-09-23 14:13:14 +1000
commit80d6bbef8661932ee0a665961b44a681c811ac36 (patch)
tree98c3bc3d36f8afa7748ef22ef2f761bb7bc29a80
parent3d751c03fe34ac8547dfd0e39d8964129ec4c095 (diff)
parent4e0d0f7d75642472abc10d500989716bbd974f41 (diff)
Merge branch 'master' of https://github.com/jesseduffield/lazygitv0.3.1
-rw-r--r--Gopkg.lock4
-rw-r--r--README.md5
-rw-r--r--go.mod2
-rw-r--r--pkg/gui/commit_message_panel.go4
-rw-r--r--pkg/gui/view_helpers.go13
-rw-r--r--pkg/utils/utils.go10
-rw-r--r--pkg/utils/utils_test.go35
-rw-r--r--vendor/github.com/jesseduffield/gocui/view.go4
8 files changed, 69 insertions, 8 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/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,
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/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..6c3e5505c 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",
@@ -183,7 +190,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 +226,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/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))
+ }
+}
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