Avoid unnecessary redraw of the preview window

This commit is contained in:
Junegunn Choi 2019-03-29 15:12:46 +09:00
parent f39ab3875e
commit 8d2fcd3518
No known key found for this signature in database
GPG Key ID: 254BC280FEF9C627

View File

@ -1652,10 +1652,13 @@ func (t *Terminal) Loop() {
} }
} }
scrollPreview := func(amount int) { scrollPreview := func(amount int) {
t.previewer.offset = util.Constrain( newOffset := util.Constrain(
t.previewer.offset+amount, 0, t.previewer.lines-1) t.previewer.offset+amount, 0, t.previewer.lines-1)
if t.previewer.offset != newOffset {
t.previewer.offset = newOffset
req(reqPreviewRefresh) req(reqPreviewRefresh)
} }
}
for key, ret := range t.expect { for key, ret := range t.expect {
if keyMatch(key, event) { if keyMatch(key, event) {
t.pressed = ret t.pressed = ret