Fix Sixel issues (#2544)

* Fix regression where previous image is not properly cleared
* Change the way fzf calculates the number of required lines to display
  an image (ceil -> floor) to fix the issue where an image is always
  rendered as a wireframe.
This commit is contained in:
Junegunn Choi 2023-10-27 14:36:14 +09:00
parent ec208af474
commit 96e31e4b78
No known key found for this signature in database
GPG Key ID: 254BC280FEF9C627

View File

@ -1936,6 +1936,7 @@ func (t *Terminal) renderPreviewSpinner() {
func (t *Terminal) renderPreviewArea(unchanged bool) {
if t.previewed.wipe && t.previewed.version != t.previewer.version {
t.previewed.wipe = false
t.pwindow.Erase()
} else if unchanged {
t.pwindow.MoveAndClear(0, 0) // Clear scroll offset display
@ -2029,8 +2030,8 @@ Loop:
if isSixel {
t.previewed.wipe = true
if t.termSize.PxHeight > 0 {
rows := util.Max(0, strings.Count(passThrough, "-")-1)
requiredLines = int(math.Ceil(float64(rows*6*t.termSize.Lines) / float64(t.termSize.PxHeight)))
rows := strings.Count(passThrough, "-")
requiredLines = int(math.Floor(float64(rows*6*t.termSize.Lines) / float64(t.termSize.PxHeight)))
}
}
@ -2168,7 +2169,6 @@ func (t *Terminal) printPreview() {
t.previewed.numLines = numLines
t.previewed.version = t.previewer.version
t.previewed.offset = t.previewer.offset
t.previewed.wipe = false
}
func (t *Terminal) printPreviewDelayed() {