I've had an autocommand in my vimrc for quite some time that
I noticed recently was causing the following error message when
activated:
Error detected while processing BufEnter Autocommands for "<buffer=3>":
E1312: Not allowed to change the window layout in this autocmd
I performed a git bisect on the Vim source and found that the bug
was introduced here:
d63a85592cef0ee4f0fec5efe2f8d66b31f01f05 is the first bad commit
commit d63a85592cef0ee4f0fec5efe2f8d66b31f01f05
Author: Bram Moolenaar <[email protected]>
Date: Sat Nov 19 11:41:30 2022 +0000
patch 9.0.0907: restoring window after WinScrolled may fail
Problem: Restoring window after WinScrolled may fail.
Solution: Lock the window layout when triggering WinScrolled.
src/errors.h | 2 ++
src/ex_docmd.c | 18 ++++++++++++-----
src/proto/window.pro | 1 +
src/version.c | 2 ++
src/window.c | 56
+++++++++++++++++++++++++++++++++++++++++++++++++---
5 files changed, 71 insertions(+), 8 deletions(-)
This is the autocommand in my vimrc and the reason for it being
there:
" If the Calendar window is open when the last non-Calendar
" window is closed, Vim continues to run with the Calendar
" window occupying the full Vim window. Fix this,
" automatically close the Calendar window if it is the only
" window.
"
autocmd BufWinEnter __Calendar
\ autocmd BufEnter <buffer> if winnr("$")==1 | quit | endif
Steps to reproduce
1. Start Vim with the following command (one line):
$ vim -N -u NONE -i NONE -c tabnew -c vnew -c 'autocmd BufEnter
<buffer> if winnr("$")==1 | quit | endif' -c 'wincmd w'
This opens a new tab, opens a new window in that tab, creates
a BufEnter autocommand in that buffer, and moves the cursor to
the right window.
2. Execute
:q
The error message appears.
3. Hit ENTER to continue. The right window has closed, but the
left window (now the only window on that tab page) remains open.
Expected behavior
At step 2, there should be no error message and both windows on the
second tab page should have closed, leaving only the first tab
page.
The right window was closed by :q. That caused the cursor to enter
the remaining window in that tab, triggering the autocommand and
closing that window and the tab.
Version of Vim
Observed on version 9.0.1034. Found to have been introduced at
version 9.0.0907.
Environment
Operating system: Ubuntu 22.04
Terminal: XTerm(373)
Value of $TERM: xterm-256color
Shell: bash
Regards,
Gary
--
--
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/20221214092230.GI16317%40phoenix.