-
-
Notifications
You must be signed in to change notification settings - Fork 487
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TagbarToggle and reopen file #750
Comments
@hnordholz can you list your procedure a little more and share what commands you are using in each case? I've tried a few different methods similar to what you are describing and I am not seeing this error message. Here is what I've tried: Attempt 1:shell: Attempt 2:shell: Attempt 3:shell: |
Well, I overlooked an important step: you need to wipe out the file from another buffer: I realized, that when you use bdelete instead of bwipe the problem does not occur. So it might not really be a bug, but a wrong usage of bwipe on my side. |
No you're not; v0.5 hasn't even been released yet. You may be using an early development snapshot, but there hasn't even been a feature freeze leading up to alpha/beta releases yet. I've complained about the upstream version scheme before because this is not clear to a lot of people. They improved the GitHub release titles but they didn't fix the in-app identification. 🤷 |
Closes preservim#750 On `:bdelete` or `:bwipe` of a file, remove the file from the known file listing even if the tagbar window is not open. Previously was only removing the file if the tagbar window was open.
Thanks @hnordholz. I was able to reproduce. There was code in place to unload the contents of a buffer from tagbar, but that was only being executed when the tagbar window was open. I've opened a PR to address this and make sure to remove the file from tagbar memory even if the tagbar window isn't open. |
Closes #750 On `:bdelete` or `:bwipe` of a file, remove the file from the known file listing even if the tagbar window is not open. Previously was only removing the file if the tagbar window was open.
Sorry, but it still doesn't work on my machine. |
edit: only able to repro before commit with Hmm... I am able to reproduce just fine before the commit with Can you capture the tagbar debug log and post that here while you are doing this to provide more info? You can use |
Ok, here is the log-file. |
I'm not seeing the logs of the event in here. From the logs it looks like only a.c was loaded... there is nothing about loading the info about loading file b.c or closing file a.c. Did you capture the logs from the whole procedure? You need to first use the |
What I did: That‘s all. My .vimrc contains only one line: In the next days I will try to debug the stuff by myself. Regards |
Yes I understand the procedure you are doing. I was able to reproduce this before the commit following the steps you provided. I am not able to reproduce this after the commit. If you are able to use the |
Thank you for your patience. I changed the procedure a little bit, to avoid the 'buggy operator'. My environment The log-file doesn't mention b.c, but when b.c was the current buffer, no tagbar was open. If this is the case, could you run the test script and send me your log file? |
Success! well kind of... i was able to repro with the commit. Turns out with the combination of plugins I have the previous commit fix for this did cause it to work for me. For me it happens to be the following lightline configuration which was causing the commit to work for me. let g:lightline = {
\ 'component_function': {
\ 'functionName': 'LightlineFunctionName',
\ },
\ }
" ---- LightlineFunctionName() {{{2
function! LightlineFunctionName()
if &filetype =~# g:ignored_filetypes
return ''
endif
return tagbar#currenttag("%s", "", 'f', 'nearest-stl')
endfunction This combined with the lightline plugin was changing the behavior in my environment slightly so with the commit, the unload of the file was working. Let me dig into it a little more and see if I can figure out what is going on. |
Ok... here is the issue. " s:CloseWindow() {{{2
function! s:CloseWindow() abort
...
if s:autocommands_done && !s:statusline_in_use
call tagbar#StopAutoUpdate()
endif
...
endfunction In my case, the autocmd BufDelete,BufWipeout * ... So there are a few ways we could fix this.
diff --git a/autoload/tagbar.vim b/autoload/tagbar.vim
index 09b6888..1da6055 100644
--- a/autoload/tagbar.vim
+++ b/autoload/tagbar.vim
@@ -582,8 +582,6 @@ function! s:CreateAutocommands() abort
autocmd CursorHoldI * call
\ s:AutoUpdate(fnamemodify(expand('<afile>'), ':p'), 0)
endif
- autocmd BufDelete,BufWipeout *
- \ nested call s:HandleBufDelete(expand('<afile>'), expand('<abuf>'))
" Suspend Tagbar while grep commands are running, since we don't want
" to process files that only get loaded temporarily to search them
@@ -596,6 +594,15 @@ function! s:CreateAutocommands() abort
endif
augroup END
+ " Separate these autocmds out from the others as we want to always perform
+ " these actions even if the tagbar window closes.
+ augroup TagbarCleanupAutoCmds
+ if !g:tagbar_no_autocmds
+ autocmd BufDelete,BufWipeout *
+ \ nested call s:HandleBufDelete(expand('<afile>'), expand('<abuf>'))
+ endif
+ augroup END
+
let s:autocommands_done = 1
endfunction
diff --git a/autoload/tagbar.vim b/autoload/tagbar.vim
index 09b6888..5f093f1 100644
--- a/autoload/tagbar.vim
+++ b/autoload/tagbar.vim
@@ -1098,10 +1098,6 @@ function! s:CloseWindow() abort
call s:ShrinkIfExpanded()
- if s:autocommands_done && !s:statusline_in_use
- call tagbar#StopAutoUpdate()
- endif
-
call tagbar#debug#log('CloseWindow finished')
endfunction
diff --git a/autoload/tagbar.vim b/autoload/tagbar.vim
index 09b6888..389aab9 100644
--- a/autoload/tagbar.vim
+++ b/autoload/tagbar.vim
@@ -1102,6 +1102,10 @@ function! s:CloseWindow() abort
call tagbar#StopAutoUpdate()
endif
+ let s:known_files = {
+ \ '_files' : {}
+ \ }
+
call tagbar#debug#log('CloseWindow finished')
endfunction
So I'll open this one up... I'm leaning toward option 1 as it would seem to have the least impact, but it does introduce a second autocmd group for tagbar. Not sure if that is a deal breaker for anybody. |
For option 3 we might want to look at better cleanup logic. Looping through each entry and doing a |
Fixes preservim#750 Once the tagbar window is opened and a file is registered, that file stays in memory even if the tagbar window is closed. This allows tagbar to cache the info so if the tagbar window is opened again, it doesn't have to rescan the file and rerun ctags on the file. However if this buffer is wiped out using `:bwipe <file>`, then the buffer is completely unloaded from vim memory and also needs to be unloaded from tagbar memory. This works if the tagbar window is open, but in the event the tagbar window is closed, all autocmds are unregistered, so tagbar never gets the BufWipeout notification. This results in tagbar leaving the buffer in active memory even though the buffer doesn't exist anymore. This fix will leave the BufWipeout and BufDelete autocmds active even if the tagbar window is closed. This allows the buffer cleanup to occur on a `:bwipe` command even if the tagbar window is closed.
@hnordholz I've pushed up a PR for this issue (#769). Can you give that a try to make sure it works for you too? |
Fixes #750 Once the tagbar window is opened and a file is registered, that file stays in memory even if the tagbar window is closed. This allows tagbar to cache the info so if the tagbar window is opened again, it doesn't have to rescan the file and rerun ctags on the file. However if this buffer is wiped out using `:bwipe <file>`, then the buffer is completely unloaded from vim memory and also needs to be unloaded from tagbar memory. This works if the tagbar window is open, but in the event the tagbar window is closed, all autocmds are unregistered, so tagbar never gets the BufWipeout notification. This results in tagbar leaving the buffer in active memory even though the buffer doesn't exist anymore. This fix will leave the BufWipeout and BufDelete autocmds active even if the tagbar window is closed. This allows the buffer cleanup to occur on a `:bwipe` command even if the tagbar window is closed.
Closes preservim#750 On `:bdelete` or `:bwipe` of a file, remove the file from the known file listing even if the tagbar window is not open. Previously was only removing the file if the tagbar window was open.
…servim#769) Fixes preservim#750 Once the tagbar window is opened and a file is registered, that file stays in memory even if the tagbar window is closed. This allows tagbar to cache the info so if the tagbar window is opened again, it doesn't have to rescan the file and rerun ctags on the file. However if this buffer is wiped out using `:bwipe <file>`, then the buffer is completely unloaded from vim memory and also needs to be unloaded from tagbar memory. This works if the tagbar window is open, but in the event the tagbar window is closed, all autocmds are unregistered, so tagbar never gets the BufWipeout notification. This results in tagbar leaving the buffer in active memory even though the buffer doesn't exist anymore. This fix will leave the BufWipeout and BufDelete autocmds active even if the tagbar window is closed. This allows the buffer cleanup to occur on a `:bwipe` command even if the tagbar window is closed.
Open File
Open Tagbar
Close Tagbar
Wipe File
Open File
Open Tagbar
Select a tag
Message:
Error detected while processing function 83_JumpToTag[11]..83_GotoFileWindow:
line 11:
E86: Buffer 4 does not exist
Suggestion:
In autoload/tagbar.vim at the end of s:CloseWindow():
Add-> let s:known_files._files = {}
endfunction
The text was updated successfully, but these errors were encountered: