fix(image): hover close in insert mode (#2215)

## Description

I'm not 100% sure if this is a bug or if it was intentional, but the
`return` seems to have been lost from a previous refactor
e35d6cd4 (diff-ff9a4f8a621887c466394f755193cc78a5e69e0e2e86f4e668662e1434d3611eL878).

When an image displays using float or hover, the image can block the
text even in insert mode. This makes editing really hard. Adding the
`return` can close the hover in insert mode.

## Related Issue(s)

I couldn't find an issue created for this, but there is a discussion
about it https://github.com/folke/snacks.nvim/discussions/1777.

## Screenshots

Before the fix, the image shows in insert mode.
<img width="704" height="710" alt="image"
src="https://github.com/user-attachments/assets/224883d1-edbc-4f7a-8c1b-91ef00dbe21e"
/>

After the fix, the image stops showing in insert mode.
<img width="389" height="127" alt="image"
src="https://github.com/user-attachments/assets/d704d4f8-9259-4e5e-b7a9-954ea6e2a788"
/>
This commit is contained in:
Jay Z 2025-10-19 06:04:44 -04:00 committed by GitHub
parent 3b14f8c1a5
commit ef59af0ffc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -347,7 +347,11 @@ function M.hover()
return
end
if hover and (not hover.win:valid() or hover.buf ~= current_buf or vim.fn.mode() ~= "n") then
if hover and (hover.buf ~= current_buf or vim.fn.mode() ~= "n") then
return M.hover_close()
end
if hover and not hover.win:valid() then
M.hover_close()
end