1
1
" File: taglist.vim
2
2
" Author: Yegappan Lakshmanan (yegappan AT yahoo DOT com)
3
- " Version: 4.0
4
- " Last Modified: September 6, 2006
3
+ " Version: 4.1
4
+ " Last Modified: September 10, 2006
5
+ " Copyright: Copyright (C) 2002-2006 Yegappan Lakshmanan
6
+ " Permission is hereby granted to use and distribute this code,
7
+ " with or without modifications, provided that this copyright
8
+ " notice is copied with it. Like anything else that's free,
9
+ " taglist.vim is provided *as is* and comes with no warranty of any
10
+ " kind, either expressed or implied. In no event will the copyright
11
+ " holder be liable for any damamges resulting from the use of this
12
+ " software.
5
13
"
6
14
" The "Tag List" plugin is a source code browser plugin for Vim and provides
7
15
" an overview of the structure of the programming language files and allows
@@ -274,8 +282,8 @@ if !exists('loaded_taglist')
274
282
\ call s: Tlist_Session_Load (<q-args> )
275
283
command ! -nargs =* -complete =file TlistSessionSave
276
284
\ call s: Tlist_Session_Save (<q-args> )
277
- command ! TlistLock - bar let Tlist_Auto_Update= 0
278
- command ! TlistUnlock - bar let Tlist_Auto_Update= 1
285
+ command ! - bar TlistLock let Tlist_Auto_Update= 0
286
+ command ! - bar TlistUnlock let Tlist_Auto_Update= 1
279
287
280
288
" Commands for enabling/disabling debug and to display debug messages
281
289
command ! -nargs =? -complete =file - bar TlistDebug
@@ -649,7 +657,7 @@ let s:tlist_file_name_idx_cache = -1
649
657
" Tlist_Get_File_Index()
650
658
" Return the index of the specified filename
651
659
function ! s: Tlist_Get_File_Index (fname)
652
- if s: tlist_file_count == 0
660
+ if s: tlist_file_count == 0 || a: fname == ' '
653
661
return -1
654
662
endif
655
663
@@ -1587,8 +1595,8 @@ function! s:Tlist_Window_Init()
1587
1595
autocmd BufUnload __Tag_List__ call s: Tlist_Post_Close_Cleanup ()
1588
1596
" Close the fold for this buffer when leaving the buffer
1589
1597
if g: Tlist_File_Fold_Auto_Close
1590
- autocmd BufWinLeave , BufLeave * silent
1591
- \ call s: Tlist_Window_Close_File_Fold (expand (' <afile>:p' ))
1598
+ autocmd BufEnter * silent
1599
+ \ call s: Tlist_Window_Open_File_Fold (expand (' <afile>:p' ))
1592
1600
endif
1593
1601
" Exit Vim itself if only the taglist window is present (optional)
1594
1602
if g: Tlist_Exit_OnlyWindow
@@ -2252,7 +2260,7 @@ function! s:Tlist_Process_File(filename, ftype)
2252
2260
let ttype = s: Tlist_Extract_Tagtype (one_line)
2253
2261
2254
2262
" Make sure the tag type is a valid and supported one
2255
- if ttype == ' ' || stridx (s: ctags_flags , ttype) == -1
2263
+ if ttype == ' ' || stridx (ctags_flags, ttype) == -1
2256
2264
" Line is not in proper tags format or Tag type is not
2257
2265
" supported
2258
2266
continue
@@ -3829,14 +3837,11 @@ endfunction
3829
3837
" When a buffer is deleted, remove the file from the taglist
3830
3838
autocmd BufDelete * silent call s: Tlist_Buffer_Removed (expand (' <afile>:p' ))
3831
3839
3832
- " Tlist_Window_Close_File_Fold
3833
- " Close the fold for the specified file
3834
- function ! s: Tlist_Window_Close_File_Fold (filename)
3835
- call s: Tlist_Log_Msg (' Tlist_Window_Close_File_Fold (' . a: filename . ' )' )
3836
- " Make sure a valid filename is supplied
3837
- if a: filename == ' '
3838
- return
3839
- endif
3840
+ " Tlist_Window_Open_File_Fold
3841
+ " Open the fold for the specified file and close the fold for all the
3842
+ " other files
3843
+ function ! s: Tlist_Window_Open_File_Fold (filename)
3844
+ call s: Tlist_Log_Msg (' Tlist_Window_Open_File_Fold (' . a: filename . ' )' )
3840
3845
3841
3846
" Make sure the taglist window is present
3842
3847
let winnum = bufwinnr (g: TagList_title )
@@ -3845,13 +3850,6 @@ function! s:Tlist_Window_Close_File_Fold(filename)
3845
3850
return
3846
3851
endif
3847
3852
3848
- " Get tag list index of the specified file
3849
- let fidx = s: Tlist_Get_File_Index (a: filename )
3850
- if fidx == -1
3851
- " File not present in the taglist window
3852
- return
3853
- endif
3854
-
3855
3853
" Save the original window number
3856
3854
let org_winnr = winnr ()
3857
3855
if org_winnr == winnum
@@ -3860,21 +3858,26 @@ function! s:Tlist_Window_Close_File_Fold(filename)
3860
3858
let in_taglist_window = 0
3861
3859
endif
3862
3860
3861
+ if in_taglist_window
3862
+ " When entering the taglist window, no need to update the folds
3863
+ return
3864
+ endif
3865
+
3863
3866
" Go to the taglist window
3864
3867
if ! in_taglist_window
3865
3868
call s: Tlist_Exe_Cmd_No_Acmds (winnum . ' wincmd w' )
3866
3869
endif
3867
3870
3868
- " Save the cursor position
3869
- let save_lnum = line ( ' . ' )
3871
+ " Close all the folds
3872
+ silent ! % foldclose
3870
3873
3871
- " Perform the requested action on the file
3872
- " Close the fold for the file
3873
- exe " silent! " . s: tlist_ { fidx}_start . " , " .
3874
- \ s: tlist_ {fidx}_end . " foldclose "
3875
-
3876
- " Move the cursor to the original location
3877
- exe save_lnum
3874
+ " Get tag list index of the specified file
3875
+ let fidx = s: Tlist_Get_File_Index ( a: filename )
3876
+ if fidx != -1
3877
+ " Open the fold for the file
3878
+ exe " silent! " . s: tlist_ {fidx}_start . " , " .
3879
+ \ s: tlist_ {fidx}_end . " foldopen "
3880
+ endif
3878
3881
3879
3882
" Go back to the original window
3880
3883
if ! in_taglist_window
0 commit comments