diff --git a/m/pager.go b/m/pager.go index 23c4dc4..6e09e58 100644 --- a/m/pager.go +++ b/m/pager.go @@ -133,6 +133,10 @@ Source Code Available at https://github.com/walles/moar/. `) +func (pm _PagerMode) isViewing() bool { + return pm == _Viewing || pm == _NotFound +} + // NewPager creates a new Pager func NewPager(r *Reader) *Pager { var name string @@ -460,6 +464,9 @@ func (p *Pager) StartPaging(screen twin.Screen) { case eventMoreLinesAvailable: // Doing nothing here is fine; screen will be refreshed on the next // iteration of the main loop. + if p.mode.isViewing() && p.scrollPosition.HasScrolledDown() && p.wasScrolledToEnd() { + p.scrollToEnd() + } case eventSpinnerUpdate: spinner = event.spinner diff --git a/m/scrollPosition.go b/m/scrollPosition.go index dc72f27..206720d 100644 --- a/m/scrollPosition.go +++ b/m/scrollPosition.go @@ -56,6 +56,10 @@ func canonicalFromPager(pager *Pager) scrollPositionCanonical { } } +func (s *scrollPosition) HasScrolledDown() bool { + return s.internalDontTouch.lineNumberOneBased > 1 || s.internalDontTouch.deltaScreenLines > 0 +} + // Create a new position, scrolled towards the end of the file func (s scrollPosition) PreviousLine(scrollDistance int) scrollPosition { return scrollPosition{