Fix invalid memory access when the preview window becomes hidden

This commit is contained in:
Junegunn Choi 2024-03-08 17:46:24 +09:00
parent 0cc27c3cc1
commit eec557b6aa
No known key found for this signature in database
GPG Key ID: 254BC280FEF9C627
1 changed files with 1 additions and 1 deletions

View File

@ -3161,7 +3161,7 @@ func (t *Terminal) Loop() {
}
t.previewer.lines = result.lines
t.previewer.spinner = result.spinner
if t.previewer.following.Enabled() {
if t.hasPreviewWindow() && t.previewer.following.Enabled() {
t.previewer.offset = util.Max(t.previewer.offset, len(t.previewer.lines)-(t.pwindow.Height()-t.previewOpts.headerLines))
} else if result.offset >= 0 {
t.previewer.offset = util.Constrain(result.offset, t.previewOpts.headerLines, len(t.previewer.lines)-1)