[Bug] Using buffer-related functions during statusline %!

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

[Bug] Using buffer-related functions during statusline %!

This post has NOT been accepted by the mailing list yet.
Hi all,

I appear to have found a bug and would be grateful for confirmation and/or

I'm using the 'statusline' function to get a per-window status line (as you
would), however it appears that there is a difference between using '%{...}'
and '%!'. The latter appears to have a bug.

Take the following two lines of code and add to your .vimrc:

A) set statusline=%{fnamemodify(bufname('%'),':p')}
B) set statusline=%!fnamemodify(bufname('%'),':p')

To reproduce:

1) from shell, type "vi x.c" (or some other filename)
2) :split y.c
3) Continuously toggle between the two windows with <C-W>w and watch the
   status lines.

With (A) above the status lines are correct all the time. With (B) above
the status line for BOTH files says "y.c" when "y.c" (the upper window) has
the focus, and when "x.c" as the focus they appear correct.

It appears that bufname() when used from '%!' is executing only within the
context of the active window, no matter which window's status line is being
drawn, whereas it actually executes within the context of the buffer for
which the status line is being drawn if using '%{...}'.

Any offers?

Thanks in advance