fix(previewer): use Snacks.image for image preview when buffer is already loaded#2639
fix(previewer): use Snacks.image for image preview when buffer is already loaded#2639shy-robin wants to merge 1 commit intoibhagwan:mainfrom
Conversation
…eady loaded When an image file is already open in a buffer, the previewer takes the `entry.bufnr` branch which copies buffer lines to a temp buffer. Since Snacks.image sets the buffer content to empty/placeholder characters (filetype "image"), this results in a blank preview. Fix by detecting image buffers (filetype == "image") and delegating to `attach_snacks_image_buf` instead of copying lines. Steps to reproduce: 1. Preview an image in fzf-lua → works 2. Open the image into a buffer 3. Preview the same image in fzf-lua again → blank (fixed) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughA conditional check is added to handle image buffers specially in the preview population logic. When an entry buffer is loaded and contains image data, the code now routes through Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
When an image file is already open in a buffer (via nvim-tree, fzf-lua, etc.), previewing the same image in fzf-lua again results in a blank preview window.
Root cause: When
entry.bufnris set and loaded, the previewer copies buffer lines to a temp buffer (nvim_buf_get_lines→nvim_buf_set_lines). However, Snacks.image sets the image buffer's filetype to"image"with empty/placeholder content — copying these lines produces a blank preview, andattach_snacks_image_bufis never reached (it's in theelsebranch).Fix: Detect image buffers (
filetype == "image") early in theentry.bufnrbranch and delegate toattach_snacks_image_bufinstead of copying lines.Steps to reproduce
Test plan
🤖 Generated with Claude Code
Summary by CodeRabbit