diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2019-03-03 23:08:07 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2019-03-03 23:08:07 +1100 |
commit | e36899d5c591c5045d1a5d676b92d61090b16e33 (patch) | |
tree | eb458b1e6e852902f01265325ba88718528076bf /pkg/gui/gui.go | |
parent | 403526bc5054b6802c583265d8574dc7c63ed8a0 (diff) |
prevent crashes when scrolling up
Diffstat (limited to 'pkg/gui/gui.go')
-rw-r--r-- | pkg/gui/gui.go | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go index a5db4c394..89b99a919 100644 --- a/pkg/gui/gui.go +++ b/pkg/gui/gui.go @@ -1,6 +1,7 @@ package gui import ( + "math" "sync" // "io" @@ -181,10 +182,8 @@ func NewGui(log *logrus.Entry, gitCommand *commands.GitCommand, oSCommand *comma func (gui *Gui) scrollUpMain(g *gocui.Gui, v *gocui.View) error { mainView, _ := g.View("main") ox, oy := mainView.Origin() - if oy >= 1 { - return mainView.SetOrigin(ox, oy-gui.Config.GetUserConfig().GetInt("gui.scrollHeight")) - } - return nil + newOy := int(math.Max(0, float64(oy-gui.Config.GetUserConfig().GetInt("gui.scrollHeight")))) + return mainView.SetOrigin(ox, newOy) } func (gui *Gui) scrollDownMain(g *gocui.Gui, v *gocui.View) error { |