preservim / tagbar

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

vim-9.0: The autoclose functionality is not behaving correctly #851

Open raven42 opened 1 year ago

raven42 commented 1 year ago

In the s:HandleOnlyWindow() routine, currently the autoclose is not behaving correctly. With the introduction of vim-9.0 (patch-9.0.907) the quit while inside an autocmd no longer functions.

Have started a fix for this to use the feedkeys(), however that doesn't handle each case. It issues the :quit no matter what even in an E173 (Additional files open), and just blows the windows away regardless. We may have to do away with the autoclose and instead guide users to a more streamlined option like this:

autocmd QuitPre * qa
yousong commented 7 months ago

Not sure if it's a proper/minimal one but the the following patch seems to fix the issue for me. The idea is taken from this link

diff --git a/autoload/tagbar.vim b/autoload/tagbar.vim
index de8b4b3..db90f53 100644
--- a/autoload/tagbar.vim
+++ b/autoload/tagbar.vim
@@ -3540,7 +3540,7 @@ function! s:HandleOnlyWindow() abort

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

That looks like it could work. If you want to push up a pull request, then if anybody else wants to help test it out as well we could get that in.