preservim / tagbar

Vim plugin that displays tags in a window, ordered by scope
https://preservim.github.io/tagbar
Other
6.09k stars 484 forks source link

Error detected while processing WinEnter Autocommands for "*"..function <SNR>38_HandleOnlyWindow[13]..<SNR>38_CloseWindow #869

Closed lijh8 closed 5 months ago

lijh8 commented 5 months ago

Hi, i'm using vim with nerdtree and tagbar. with both nerdtree and tagbar toggled on, when i quit editing my last c++ source file, there's this error. Do not know whether it's related to nerdtree, tagbar, or vim.

https://github.com/preservim/nerdtree ,

Error detected while processing WinEnter Autocommands for "*"..function <SNR>38_HandleOnlyWindow[13]..<SNR>38_CloseWindow:
line   21:
E1312: Not allowed to change the window layout in this autocmd

this is ~/.vimrc:


set expandtab
set hlsearch
set nowrapscan
set shiftwidth=4
set smartindent
set tabstop=4
syntax off

" NERDTree
autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif
autocmd BufEnter * if winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif
autocmd VimEnter * NERDTree
let g:NERDTreeNodeDelimiter = "\u00a0"
nnoremap <leader>n :NERDTreeFocus<CR> " \ - n
nnoremap <C-n> :NERDTree<CR>          " Ctrl - n
nnoremap <C-t> :NERDTreeToggle<CR>    " Ctrl - t
nnoremap <C-f> :NERDTreeFind<CR>

" tagbar
filetype on            " Tagbar: Filetype detection is turned off, skipping plugin
let g:tagbar_sort = 0  " order of position
nmap <F8> :TagbarToggle<CR>

Screen Shot 2024-02-01 at 22 33 58 Screen Shot 2024-02-01 at 22 34 04

raven42 commented 5 months ago

I'm guessing you are running vim-9.0. This is a new issue that has been reported in #851. Some of the auto-command behavior has changed with vim-9.0. Unfortunately I haven't been able to come up with a good workaround yet (just haven't been able to spend time on it). We are open to PRs if anyone else has any ideas or options that will work.

Closing this for now as duplicate of #851.

@lijh8 if you are NOT running vim-9.0 and seeing this behavior, please reopen this issue, but otherwise we will track under the original issue.

yousong commented 4 months ago

Hi @lijh8 , I just created a small pull request for fixing this issue. Please consider giving it a try ;)

yousong commented 4 months ago

Hi @lijh8 , I just created a small pull request for fixing this issue. Please consider giving it a try ;)

Oops, here is the link to the pull request: https://github.com/preservim/tagbar/pull/875

lijh8 commented 4 months ago

here is the link to the pull request: #875

Hi, when I open both nerdtree and tagbar in vim and then :quit, it still needs this in ~/.vimrc:

autocmd QuitPre * qall 

Or, it reports this:

Error detected while processing WinEnter Autocommands for "*"..function <SNR>40_HandleOnlyWindow[13]..<SNR>40_CloseWindow:
line   21:
E1312: Not allowed to change the window layout in this autocmd

$ pwd /Users/ljh/.vim/pack/vendor/start/tagbar/autoload $ $ diff -ru tagbar.vim.bak tagbar.vim

--- tagbar.vim.bak  2024-02-29 20:26:44.000000000 +0800
+++ tagbar.vim  2024-02-29 20:32:33.000000000 +0800
@@ -3541,7 +3541,9 @@

         try
             try
-                quit
+                " quit
+                call timer_start(0, {-> execute('q', 'silent!') })
+
             catch /.*/ " This can be E173 and maybe others
                 call s:OpenWindow('')
                 echoerr v:exception

$