Skip to content

Commit

Permalink
Fix Sixel issues (#2544)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
junegunn committed Oct 27, 2023
1 parent ec208af commit 96e31e4
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/terminal.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)))
}
}

Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit 96e31e4

Please sign in to comment.