Fix kitty image leaving behind images after removing image placements #4995
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
[DRAFT] This PR is not intended to be merged right now.
This should fix #2422, but the fix in commit 319a537 will have serious performance issues for cases with big scrollbacks and lots of image updates. The "fix" is to ignore
PlacementInfo
(that might be stale) and go through all the scrollback removing the image.The main issues seems to be that
StableRowIndex
can become stale whenever a window resizing changes the amount of columns enough so as to add more lines by wrapping other lines. After wrapping, the image will get displaced (this is in kitty's implementation does not happen), and so thePlacementInfo
that is stored for thatimage_id
andplacement_id
is no longer valid.It seems to me that it would be a better approach to keep the original way of removing the images by their
PlacementInfo
(instead of going through all the scrollback), and prevent the images from being moved by lines being wrapped. The problem I see here is that this handling of the cell properties of those lines will need to be done wherever the lines are being wrapped and I'm not sure you'll be too happy about adding logic about images there (for being so unrelated).Let me know if you have any ideas or thoughts about how we could address this.
Minimal Reproduction
Kitty(reference):
Wezterm(main):
Wezterm(this PR):
Another issue tangentially related to this is that images are not occluded when a new pane appears:
In this case there isn't a way to update displayed images when the geometry of the pane changes. A way to handle these geometry changes in general would also solve the resizing.