fix(image.inline): keep placements when find_visible returns no images#2898
Open
carlos-algms wants to merge 1 commit into
Open
fix(image.inline): keep placements when find_visible returns no images#2898carlos-algms wants to merge 1 commit into
carlos-algms wants to merge 1 commit into
Conversation
`find_visible` is treesitter-backed and intermittently returns zero images while the parser reparses a rapidly-changing buffer (e.g. streaming text into a markdown buffer holding an inline image), even though the image is still present. The empty result was treated as "all images gone", closing the placement; the next non-empty parse recreated it, so every edit closed and recreated the placement = visible flicker. Treat an empty result as inconclusive and keep existing placements, reconciling only when `find_visible` actually reports images. Tradeoff: going from N images to 0 defers closing the last placement until a later non-empty `find_visible`.
carlos-algms
marked this pull request as ready for review
June 28, 2026 18:41
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Inline images flicker on rapidly-appending buffers (e.g. streaming chat output into a markdown buffer with an inline image).
Snacks.image.doc.find_visibleis treesitter-backed and intermittently returns zero images while the parser is mid-reparse during streaming, even though the image is still in the buffer.Treat an empty result as inconclusive: keep existing placements, reconcile only when
find_visiblereports images.Tradeoff: N images → 0 defers closing the last placement until a later non-empty
find_visible.One-line guard; no behavior change for non-streaming buffers.