From 03d02d67f7ae16b19d9933648d5cbd49915c76e0 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Wed, 4 Jan 2023 22:00:00 +0900 Subject: [PATCH] Fix cyclic scrolling with non-zero preview header lines e.g. fzf --preview-window 'cycle,~2' --preview 'echo foo; echo bar; seq 100' --- src/terminal.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/terminal.go b/src/terminal.go index 48f9f1d..f4435a6 100644 --- a/src/terminal.go +++ b/src/terminal.go @@ -2652,10 +2652,12 @@ func (t *Terminal) Loop() { } t.previewer.following = false numLines := len(t.previewer.lines) + headerLines := t.previewOpts.headerLines if t.previewOpts.cycle { - newOffset = (newOffset + numLines) % numLines + offsetRange := numLines - headerLines + newOffset = ((newOffset-headerLines)+offsetRange)%offsetRange + headerLines } - newOffset = util.Constrain(newOffset, t.previewOpts.headerLines, numLines-1) + newOffset = util.Constrain(newOffset, headerLines, numLines-1) if t.previewer.offset != newOffset { t.previewer.offset = newOffset req(reqPreviewRefresh)