fix(image): return converted filename instead of original src. Closes #1213

This commit is contained in:
Folke Lemaitre 2025-02-16 12:19:23 +01:00
parent 1cbe84ea53
commit 118eab0cfd
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040
2 changed files with 4 additions and 3 deletions

View file

@ -59,7 +59,7 @@ function M:on_send()
end
function M:ready()
return (not self._convert or self._convert:is_closing()) and (self.file and vim.fn.filereadable(self.file) == 1)
return (not self._convert or self._convert:is_closing()) and self.file and vim.fn.filereadable(self.file) == 1
end
function M:convert()
@ -75,7 +75,7 @@ function M:convert()
src = vim.fs.normalize(src)
end
local fin = src .. "[0]"
local root = vim.fn.stdpath("cache") .. "/snacks/image"
local root = Snacks.image.config.cache
vim.fn.mkdir(root, "p")
src = root .. "/" .. Snacks.util.file_encode(fin) .. ".png"
if vim.fn.filereadable(src) == 1 then
@ -91,7 +91,7 @@ function M:convert()
end)
end
end)
return self.src
return src
end
-- create the image

View file

@ -75,6 +75,7 @@ local defaults = {
spell = false,
statuscolumn = "",
},
cache = vim.fn.stdpath("cache") .. "/snacks/image",
debug = false,
env = {},
}