From 9d79d32c94820effd0aa415a7fea522116781333 Mon Sep 17 00:00:00 2001 From: KOREAN139 Date: Thu, 8 Nov 2018 19:35:05 +0900 Subject: [PATCH] add scroll-past-bottom configuration option with gui.scrollPastBottom option true, lazygit let user scroll past the bottom - which is default if option is false, user cannot scroll further when bottom of file has appeared in mainView --- docs/Config.md | 1 + pkg/config/app_config.go | 1 + pkg/gui/gui.go | 7 ++++++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/docs/Config.md b/docs/Config.md index 7f342df7f..dfbbdb10b 100644 --- a/docs/Config.md +++ b/docs/Config.md @@ -6,6 +6,7 @@ gui: # stuff relating to the UI scrollHeight: 2 # how many lines you scroll by + scrollPastBottom: true # enable scrolling past the bottom theme: activeBorderColor: - white diff --git a/pkg/config/app_config.go b/pkg/config/app_config.go index 7cde63de1..f789349b4 100644 --- a/pkg/config/app_config.go +++ b/pkg/config/app_config.go @@ -214,6 +214,7 @@ func GetDefaultConfig() []byte { `gui: ## stuff relating to the UI scrollHeight: 2 + scrollPastBottom: true theme: activeBorderColor: - white diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go index 35448922a..ee8fb1165 100644 --- a/pkg/gui/gui.go +++ b/pkg/gui/gui.go @@ -130,7 +130,12 @@ func (gui *Gui) scrollUpMain(g *gocui.Gui, v *gocui.View) error { func (gui *Gui) scrollDownMain(g *gocui.Gui, v *gocui.View) error { mainView, _ := g.View("main") ox, oy := mainView.Origin() - if oy < len(mainView.BufferLines()) { + y := oy + if !gui.Config.GetUserConfig().GetBool("gui.scrollPastBottom") { + _, sy := mainView.Size() + y += sy + } + if y < len(mainView.BufferLines()) { return mainView.SetOrigin(ox, oy+gui.Config.GetUserConfig().GetInt("gui.scrollHeight")) } return nil