-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[bug] Image hijack does not work with :vs
#60
Comments
:vs
:vs
Hey, thanks for the issue! |
Done, good thing you mentioned image-hijack-split.mp4 |
Thanks for the implementation! However, may I ask you why you chose The following code does not work. -- start with a blank (or a non-image) window
local leftwin = vim.api.nvim_get_current_win()
local test_img_path = "/path/to/image.png"
vim.cmd.vsplit(test_img_path)
local rightwin = vim.api.nvim_get_current_win()
local rightbuf = vim.api.nvim_get_current_buf()
-- `test_img_path` loaded into the right window.
-- works because this was the first time to load the image,
-- hence autocmd `BufRead` kicks in.
vim.api.nvim_win_set_buf(leftwin, rightbuf)
-- image should be loaded into the left window as well (without focusing!!)
-- cursor remains at the right window
vim.api.nvim_buf_get_name(vim.api.nvim_win_get_buf(leftwin)) == test_img_path
-- but image not rendered because it is not `BufRead`
-- AND not `WinEnter` because the buffer was loaded without focusing the left window
-- Image not rendered on left window !!! To be clear, if this is intentional, I have no problem and I can deal with this problem inside neo-tree. Just wanted to make sure that it is possible to load a buffer inside a window without invoking |
Ah we need BufWinEnter as well, will add. |
If we have WinBufEnter, now I think we actually don't need WinEnter. |
BufWinEnter doesn't work with |
Hi, thanks again for implementing the image preview feature for
png
etc files.Please forgive me if I'm wrong, but as I was testing your code I think we need more events than only
BufRead
to work properly.For example, when calling
:vsplit
, the image does not appear on the second window.I guess we should use
{ "BufRead", "BufWinEnter" }
to make this work?To be exact, I believe this issue comes from the code below, where
has_valid_filetype
does not takeoptions.hijack_file_patterns
into account. But in real world, since the image buffer cannot be modified, we don't need for exampleCursorMoved, Insert*
, nor opened as a new empty buffer (BufNew
etc), which results in covering all cases with justBufRead, BufWinEnter
?image.nvim/lua/image/utils/document.lua
Lines 130 to 186 in 1cb60be
The text was updated successfully, but these errors were encountered: