Hi,

On Mon, Jun 15, 2020 at 9:22 AM itchyny <[email protected]> wrote:

> *Is your feature request about something that is currently impossible or
> hard to do? Please describe the problem.*
> The :doautoall command uses the temporary window (aucmd_win) for a buffer
> which does not belong to the visible windows. But we cannot distinguish the
> temporary window for :doautoall and normal windows.
>
> :autocmd BufEnter * echom [bufname(), winnr(), winnr('$')]
>
> :edit a" ['a', 1, 1]
> :tabnew b" ['b', 1, 1]
> " We expect winnr('$') always returns the window count, however
> :doautoall BufEnter" ['a', 1, 2] => winnr('$') returns 2 due to aucmd_win" 
> ['b', 1, 1]
>
> :autocmd! BufEnter *
>
> :autocmd BufEnter * echom map(range(1, winnr('$')), 
> '[bufname(winbufnr(v:val)), winnr() == v:val]')
>
> :doautoall BufEnter" [['a', 1], ['b', 0]]" [['b', 1]]
>
> :tabp" [['a', 1]]
> " We expect that the window number is equal to winnr() only for the active 
> window, however
> :doautoall BufEnter" [['a', 1]]" [['b', 1], ['a', 0]] " => The 'b' buffer is 
> associated with aucmd_win
>
> This behavior confuses plugins which assume that winnr() always returns
> the active window number, but this is incorrect due to :doautoall
> command. This happens with any events because :doautoall does not
> restrict the event to emit. User can :doautoall FileType or even :doautoall
> WinEnter. The plugins cannot tell the event is fired with :doautoall or
> not.
>
> The issue occurs when using sessions too. The session file created by
> :mksession contains doautoall SessionLoadPost (see src/session.c#L1253
> <https://github.com/vim/vim/blob/47a519a933e8bcaf703a5feaac5c01491a658ee3/src/session.c#L1253>),
> which makes the same problem happen.
>
> *Describe the solution you'd like*
> Provide a way to detect a window is aucmd_win or not within Vim script.
> Something like v:aucmd_win_used or expand('<awinused>'). Or provide a
> function whether or not a window is listed or not
> <https://github.com/vim/vim/blob/47a519a933e8bcaf703a5feaac5c01491a658ee3/src/window.c#L5044-L5048>
> .
>

If the getwininfo() function returns whether a window is an autocmd window
or not, will that meet
this requirement?

- Yegappan


> *Describe alternatives you've considered*
> The :doautoall command with any events causes the problem but I'm
> troubled with the fact that session file contains the :doautoall command.
> Does it need to fire SessionLoadPost with doautoall actually? I don't
> need it to emit the event for all the buffers, but just want to do
> something once on session load. I suggest adding another event which is
> fired only once on session load OR just add doautocmd WinEnter at the end
> of the session.
>
> *Additional context*
> Original issue: itchyny/lightline.vim#448
> <https://github.com/itchyny/lightline.vim/issues/448>
>
>
>

-- 
-- 
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].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/CAAW7x7n_nuzt%3DFhm8e3qN88yVNXxn3pjmgVw23AeycvDCH0%3DpA%40mail.gmail.com.

Raspunde prin e-mail lui