-
Notifications
You must be signed in to change notification settings - Fork 126
Open
Labels
Description
To reproduce, open vim and create a second tab, then print the list of all vim.windows
.
$ vim # or nvvim
:tabedit
:python3 print(list(vim.windows))
Under Vim this only returns the windows in the currently visible buffer, i.e. [<window 0>]
. Under Neovim this returns all windows in all buffers, i.e. [<Window(handle=1000)>, <Window(handle=1001)>]
. This is inconsistent behavior to Vim.
This yields problems when you for example iterate through all windows and try to do actions within them, like so:
def _close_all():
for idx,win in enumerate(vim.windows, 1):
vim.command("%iwincmd w" % idx)
if "nofile" in vim.eval("&buftype"):
vim.command(":bwipeout")
return _close_all()
I also realize that Vim is explicit about its behaviour and pynvim is not implementing it correctly. This is from :help python
:
< Note: vim.windows object always accesses current tab page.
|python-tabpage|.windows objects are bound to parent |python-tabpage|
object and always use windows from that tab page (or throw vim.error
in case tab page was deleted). You can keep a reference to both
without keeping a reference to vim module object or |python-tabpage|,
they will not lose their properties in this case.