Hi, :help bufwinnr says:
"Only deals with the current tab page."
Recently i found that this behaviour is broken if the argument of
bufwinnr() is regexp pattern and there are more than one tabs open. I found
that in following experiment:
1. Open vim with some file.
2. Open NERD_tree plugin (its bufname will be 'NERD_tree_1')
3. :echo bufname('NERD_tree*') -> 1 (if it's open on the left), good
4. Open another file in a new tab.
5. Open another NERD_tree in this new tab (its name will be 'NERD_tree_2')
6. :echo bufname('NERD_tree*') -> -1 (bad, shoul be 1 because another
NERD_tree is in another tab!)
7. Return to the first tab and do :echo.... again -> -1 (must be 1)
The issue is due to f_bufwinnr() in eval.c calls get_buf_tv() which in turn
calls buflist_findpat(). buflist_findpat() searches through buffers in all
windows and when it finds more than one matches it returns -2! According to
the idea of bufwinnr it should check only in buffers that bound to the
current tab so buflist_findpat() must sort out buffers from other tabs. I
implemented and attached a small patch that fixes this issue for me: this
adds extra argument 'curtab_only' in get_buf_tv() and buflist_findpat(),
the latter function adds a match only if matched buffer is bound to the
current tab. Though I am not sure that it is clean enough (especially when
i am adding curtab_only as the last argument to the buflist_findpat(),
which previous argument marked with macro UNUSED).
Cheers, Alexey.
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.
vim-bufwinnr-regex-fails-in-tabs.patch
Description: Binary data
