All,
I've been using the following pair of autocommands
to keep Vim from scrolling the my buffers when I switch
them:
if v:version >= 700
autocmd BufLeave * let b:winview = winsaveview()
autocmd BufEnter * if (exists('b:winview')) |
\call winrestview(b:winview) |
\endif
endif
This has an undesirable interaction with the taglist plugin
with these settings:
let Tlist_GainFocus_On_ToggleOpen = 1
let Tlist_Close_On_Select = 1
After executing :TlistToggle, selecting a tag, and pressing
Enter, the expected behavior is to jump to the location for
that tag. But the above autocommands undo the jump, leaving
the cursor at its original position.
Below is a patch to version 4.5 of taglist.vim that fixes this
behavior. It wraps the :close command with taglist's
s:Tlist_Exe_Cmd_No_Acmds() function to prevent activation
of the autocommand.
It's not clear to me how many other places in taglist.vim might
have a similar interaction. The :close command is used without
suppressing autocommands in several places that could
perhaps have similar unwanted effects.
--- taglist.vim (revision 478)
+++ taglist.vim (working copy)
@@ -3289,7 +3289,7 @@
" tag is selected, close the taglist window
if g:Tlist_Close_On_Select
call s:Tlist_Window_Goto_Window()
- close
+ call s:Tlist_Exe_Cmd_No_Acmds('close')
" Go back to the window displaying the selected file
let wnum = bufwinnr(a:filename)
I've tested the problem and the patch with a clean configuration
of Vim 7.2.191, with the following ~/.vimrc and ~/.vim/ tree:
testuser@t61:~$ cat ~/.vimrc
filetype on
let Tlist_Close_On_Select = 1
let Tlist_GainFocus_On_ToggleOpen = 1
nmap <silent> <s-F8> :TlistToggle<CR>
if v:version >= 700
autocmd BufLeave * let b:winview = winsaveview()
autocmd BufEnter * if (exists('b:winview')) |
\call winrestview(b:winview) |
\endif
endif
testuser@t61:~$ find ~/.vim
/home/testuser/.vim
/home/testuser/.vim/doc
/home/testuser/.vim/doc/taglist.txt
/home/testuser/.vim/plugin
/home/testuser/.vim/plugin/taglist.vim
/home/testuser/.vim/plugin/taglist.vim.orig
Michael Henry