Skip to content

fix: clear snacks images in wezterm when they leave the screen - #43

Merged
wu-json merged 1 commit into
mainfrom
fix/wezterm-image-leftovers
Nov 1, 2026
Merged

wu-json merged 1 commit into
mainfrom
fix/wezterm-image-leftovers

Conversation

@wu-json

@wu-json wu-json commented Nov 1, 2026

Copy link
Copy Markdown
Owner

Problem

In WezTerm, images rendered by snacks.nvim stayed on screen:

  • after opening a png/jpg buffer and switching to another buffer
  • after glossing over an image in an fzf-lua preview (even without selecting it), leaving remnants over later buffers

Root cause

WezTerm doesn't support Kitty unicode placeholders, so snacks draws images at fixed screen positions that persist until the terminal receives an explicit delete (:redraw! does not clear them). Snacks never sent that delete because:

  1. placement:hide() only flags the image hidden.
  2. fzf-lua swaps/wipes preview buffers with autocmds ignored, so snacks' BufWipeout cleanup and BufWinLeave hooks never fire.
  3. placement:update() returns early once the buffer is invalid (ready() is false), so it never reaches its own delete branch.

Fix

  • lua/config/image.lua: wrap snacks' placement hide/del/update to send the Kitty delete in fallback (no-placeholder) mode and close placements whose buffer is gone; track live placements so they can be re-checked.
  • lua/plugins/image.lua: after fzf-lua's set_preview_buf, re-check all placements.

Testing

Reproduced in a separate WezTerm window driven via nvim --server with screenshots at each step. Before: leftover images after preview changes, fzf close, and buffer switches. After: all clean; opening an image still shows it in its buffer and it reappears when switching back.

🤖 Generated with Claude Code

WezTerm has no Kitty unicode placeholders, so Snacks draws images at fixed
screen positions that stay until the terminal gets an explicit delete.
Snacks never sent it when an image buffer left its window, and fzf-lua
swaps preview buffers with autocmds ignored, so previews were left behind.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@wu-json
wu-json merged commit 0e147dd into main Nov 1, 2026
1 of 2 checks passed
@wu-json
wu-json deleted the fix/wezterm-image-leftovers branch November 1, 2026 01:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant