Closed benlubas closed 5 months ago
I'm pretty sure this setup is just rending two images on top of eachother and then they're getting split.
I'm also able to reproduce this now, independent of the split window/image in the split window. I'm not sure what was causing that behavior for me yesterday. Maybe just unfortunate luck
Really specific scenario, but it's something that breaks a feature I want to add to molten.
The overview goes like this: if there's an image in your buffer, and a split buffer with other images, and you clear the image in your buffer and then rerender it very quickly, two images will show up (along with artifacts sometimes) where there should be one.
Video
https://github.com/3rd/image.nvim/assets/56943754/1a55ecf0-9cbb-490f-859b-6641a9b626cb
Reproduction Steps
file_path
variable name<leader>M
(a keymap that will unrender the image in the main buffer and immediately replace it with another image)local content = [[
Hello World
I'm going to place an image below here via the api
other lines ]]
vim.schedule(function() local image = require("image") local img local original_win = vim.api.nvim_get_current_win() local original_buf = vim.api.nvim_get_current_buf() local buf = vim.api.nvim_create_buf(false, true) vim.api.nvim_buf_set_lines(buf, 0, -1, true, vim.split(content, "\n")) vim.api.nvim_buf_set_option(buf, "filetype", "markdown") vim.cmd("vs") vim.api.nvim_set_current_buf(buf)
image .from_file(file_path, { y = 3, with_virtual_padding = true, buffer = buf, window = vim.api.nvim_get_current_win(), }) :render() image .from_file(file_path, { y = 5, with_virtual_padding = true, buffer = buf, window = vim.api.nvim_get_current_win(), }) :render()
img = image .from_file(file_path, { y = 15, with_virtual_padding = true, buffer = original_buf, window = original_win, }) img:render() vim.keymap.set("n", "M", function()
img:clear()
img = image
.from_file(file_path, {
y = 15,
with_virtual_padding = true,
buffer = original_buf,
window = original_win,
})
img:render()
end)
end)