From 4e25f78507b9d8e3aa1dbba16cdb860d10cb5692 Mon Sep 17 00:00:00 2001 From: winhung Date: Tue, 6 Aug 2019 21:46:24 +0800 Subject: [PATCH] scrollDownMain now works properly with ScrollPastBottom enabled #31 --- pkg/gui/main_panel.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/pkg/gui/main_panel.go b/pkg/gui/main_panel.go index 548845284..dc3e2a52e 100644 --- a/pkg/gui/main_panel.go +++ b/pkg/gui/main_panel.go @@ -16,21 +16,20 @@ func (gui *Gui) scrollUpMain(g *gocui.Gui, v *gocui.View) error { func (gui *Gui) scrollDownMain(g *gocui.Gui, v *gocui.View) error { mainView := gui.getMainView() + mainView.Autoscroll = false ox, oy := mainView.Origin() - y := oy + + reservedLines := 0 if !gui.Config.UserConfig.Gui.ScrollPastBottom { - _, sy := mainView.Size() - y += sy + _, sizeY := mainView.Size() + reservedLines = sizeY } - _, sizeY := mainView.Size() totalLines := mainView.ViewLinesHeight() - if oy+sizeY >= totalLines { + if oy+reservedLines >= totalLines { return nil } - // for some reason we can't work out whether we've hit the bottomq - // there is a large discrepancy in the origin's y value and the length of BufferLines return mainView.SetOrigin(ox, oy+gui.Config.UserConfig.Gui.ScrollHeight) }