gokcehan/lf

ueberzug image preview not refresh when resizing terminal after r28

Closed this issue · 4 comments

This is r28

2022-12-26_14-36-25.mp4

This is r27

2022-12-26_14-37-27.mp4

I use this script with ueberzug to preview image.

I have the same issue with ctpv after updating to r28

This regression seems to be introduced in e10ef91. Specifically:

lf/ui.go

Lines 682 to 684 in b47cf6d

if curr.path == ui.currentFile {
return
}

where the preview won't reload since the selected file did not change.

@laktak If you are around, please take a look.

After upgrading to version r28, I also noticed that running $true (or any other shell command) in the command line would cause an image preview to disappear.

When a shell command is run, the cleaner script is invoked to clear the preview. Prior to this version, the previewer script would also be invoked afterwards to restore the preview. However, because of the regression mentioned by @SeekingBlues, the previewer script is not invoked anymore because the current file hasn't changed and the function returns early.

If the current file hasn't changed, then I think the correct behaviour is to not call the on-select command and continue executing the rest of the function. Something like this:

--- a/ui.go
+++ b/ui.go
@@ -679,11 +679,10 @@ func (ui *ui) loadFile(app *app, volatile bool) {
 		return
 	}
 
-	if curr.path == ui.currentFile {
-		return
+	if curr.path != ui.currentFile {
+		ui.currentFile = curr.path
+		onSelect(app)
 	}
-	ui.currentFile = curr.path
-	onSelect(app)
 
 	if !gOpts.preview {
 		return