-
Notifications
You must be signed in to change notification settings - Fork 332
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Horizontal resizing does not flush cached sixels #1452
Comments
Thanks for reporting. I guess that most of the other users who were interested in sixel previews never encountered this issue because they just used The reason why the file preview cache is only cleared on vertical resizing is because it predates sixel support. Originally, file previews only supported text content, which is implemented as an array of strings, limited to the height of the preview window. For instance if the preview window has a height of 30 lines, then only the first 30 lines of the file would be read and stored for previewing. This also means that if the height of the preview window increases, the preview would no longer be valid and have to be reloaded. Horizontal resizing doesn't matter in this case since entire lines are stored, and lines are simply truncated if they exceed the width of the preview window. I guess we could fix this by unconditionally invalidating the file preview cache if diff --git a/eval.go b/eval.go
index ff04308..23df598 100644
--- a/eval.go
+++ b/eval.go
@@ -1940,6 +1940,9 @@ func (e *callExpr) eval(app *app, args []string) {
app.nav.height = app.ui.wins[0].h
app.nav.regCache = make(map[string]*reg)
}
+ if gOpts.sixel {
+ app.nav.regCache = make(map[string]*reg)
+ }
for _, dir := range app.nav.dirs {
dir.boundPos(app.nav.height)
} We might also have to do something similar in other places where the horizontal size of the preview window can change, for example if the |
I read the entire PR and found that you have already discussed this issue here #1211 (comment) and here #1211 (comment) but it remained unsolved. I also noticed that @horriblename added the To me your solution is fine because it doesn't affect the users who don't use the sixels. But as you guessed, the same problem occurs when you change the |
nope, this is the only problem @joelim-work I'll make a PR from your patch above, there's one other thing that needs to be done (force filler to redraw) |
I just noticed that the same cropping problem occurs when using symbols in chafa: So it seems to me that we always need to invalidate the file preview cache regardless of whether we resize the terminal window horizontally or vertically. Because we never know which previewer tools actually depend on the width and height attributes of the preview pane. |
@joelim-work I read that you are releasing a new version. Is it too much to ask to have this fixed in there as it is very easy to fix? I have no idea what the "force filler to redraw" issue @horriblename mentioned is, but I don't think we need to worry about it now since everything seems to be working fine with the suggested fix. |
I think the "force filler to redraw" is referring to this code: Lines 60 to 65 in 43c2683
But alternating between bold/regular to clear the image only happens when drawing the preview for a different file, not if the size of the preview changes for the current file. I found a way to work around it though, by setting That being said, I think alternating between bold/regular to clear sixel images is specific to only some terminal emulators, though I'm not 100% sure about this. Anyway I submitted #1629, hopefully that should fix your issue. |
Your fix works as expected. Thanks a lot! |
When you resize the terminal window horizontally, lf does not flush the cache and reload the images. So you get a cropped image as you can see below.
But if you resize vertically, the cache will be flushed and the images will be reloaded.
According to this commit 628bf40, it's designed to work that way, but it's unclear why the cache is flushed only on vertical resizing.
I'm using the following previewer:
Note that I don't use the
exit 1
command because I don't want to disable image caching.The text was updated successfully, but these errors were encountered: