Version 4.1

When the Tlist_File_Fold_Auto_Close variable is set to 1, jumping to the taglist window closes all the folds. Modified the plugin to not close the fold for the currently active file. When the TlistLock and TlistUnlock commands are invoked, an error message is displayed. This problem is fixed.
This commit is contained in:
Yegappan Lakshmanan 2006-09-10 00:00:00 +00:00 committed by Able Scraper
parent 8520cb9123
commit 56fac4dbda
1 changed files with 35 additions and 32 deletions

View File

@ -1,7 +1,15 @@
" File: taglist.vim " File: taglist.vim
" Author: Yegappan Lakshmanan (yegappan AT yahoo DOT com) " Author: Yegappan Lakshmanan (yegappan AT yahoo DOT com)
" Version: 4.0 " Version: 4.1
" Last Modified: September 6, 2006 " Last Modified: September 10, 2006
" Copyright: Copyright (C) 2002-2006 Yegappan Lakshmanan
" Permission is hereby granted to use and distribute this code,
" with or without modifications, provided that this copyright
" notice is copied with it. Like anything else that's free,
" taglist.vim is provided *as is* and comes with no warranty of any
" kind, either expressed or implied. In no event will the copyright
" holder be liable for any damamges resulting from the use of this
" software.
" "
" The "Tag List" plugin is a source code browser plugin for Vim and provides " The "Tag List" plugin is a source code browser plugin for Vim and provides
" an overview of the structure of the programming language files and allows " an overview of the structure of the programming language files and allows
@ -274,8 +282,8 @@ if !exists('loaded_taglist')
\ call s:Tlist_Session_Load(<q-args>) \ call s:Tlist_Session_Load(<q-args>)
command! -nargs=* -complete=file TlistSessionSave command! -nargs=* -complete=file TlistSessionSave
\ call s:Tlist_Session_Save(<q-args>) \ call s:Tlist_Session_Save(<q-args>)
command! TlistLock -bar let Tlist_Auto_Update=0 command! -bar TlistLock let Tlist_Auto_Update=0
command! TlistUnlock -bar let Tlist_Auto_Update=1 command! -bar TlistUnlock let Tlist_Auto_Update=1
" Commands for enabling/disabling debug and to display debug messages " Commands for enabling/disabling debug and to display debug messages
command! -nargs=? -complete=file -bar TlistDebug command! -nargs=? -complete=file -bar TlistDebug
@ -649,7 +657,7 @@ let s:tlist_file_name_idx_cache = -1
" Tlist_Get_File_Index() " Tlist_Get_File_Index()
" Return the index of the specified filename " Return the index of the specified filename
function! s:Tlist_Get_File_Index(fname) function! s:Tlist_Get_File_Index(fname)
if s:tlist_file_count == 0 if s:tlist_file_count == 0 || a:fname == ''
return -1 return -1
endif endif
@ -1587,8 +1595,8 @@ function! s:Tlist_Window_Init()
autocmd BufUnload __Tag_List__ call s:Tlist_Post_Close_Cleanup() autocmd BufUnload __Tag_List__ call s:Tlist_Post_Close_Cleanup()
" Close the fold for this buffer when leaving the buffer " Close the fold for this buffer when leaving the buffer
if g:Tlist_File_Fold_Auto_Close if g:Tlist_File_Fold_Auto_Close
autocmd BufWinLeave,BufLeave * silent autocmd BufEnter * silent
\ call s:Tlist_Window_Close_File_Fold(expand('<afile>:p')) \ call s:Tlist_Window_Open_File_Fold(expand('<afile>:p'))
endif endif
" Exit Vim itself if only the taglist window is present (optional) " Exit Vim itself if only the taglist window is present (optional)
if g:Tlist_Exit_OnlyWindow if g:Tlist_Exit_OnlyWindow
@ -2252,7 +2260,7 @@ function! s:Tlist_Process_File(filename, ftype)
let ttype = s:Tlist_Extract_Tagtype(one_line) let ttype = s:Tlist_Extract_Tagtype(one_line)
" Make sure the tag type is a valid and supported one " Make sure the tag type is a valid and supported one
if ttype == '' || stridx(s:ctags_flags, ttype) == -1 if ttype == '' || stridx(ctags_flags, ttype) == -1
" Line is not in proper tags format or Tag type is not " Line is not in proper tags format or Tag type is not
" supported " supported
continue continue
@ -3829,14 +3837,11 @@ endfunction
" When a buffer is deleted, remove the file from the taglist " When a buffer is deleted, remove the file from the taglist
autocmd BufDelete * silent call s:Tlist_Buffer_Removed(expand('<afile>:p')) autocmd BufDelete * silent call s:Tlist_Buffer_Removed(expand('<afile>:p'))
" Tlist_Window_Close_File_Fold " Tlist_Window_Open_File_Fold
" Close the fold for the specified file " Open the fold for the specified file and close the fold for all the
function! s:Tlist_Window_Close_File_Fold(filename) " other files
call s:Tlist_Log_Msg('Tlist_Window_Close_File_Fold (' . a:filename . ')') function! s:Tlist_Window_Open_File_Fold(filename)
" Make sure a valid filename is supplied call s:Tlist_Log_Msg('Tlist_Window_Open_File_Fold (' . a:filename . ')')
if a:filename == ''
return
endif
" Make sure the taglist window is present " Make sure the taglist window is present
let winnum = bufwinnr(g:TagList_title) let winnum = bufwinnr(g:TagList_title)
@ -3845,13 +3850,6 @@ function! s:Tlist_Window_Close_File_Fold(filename)
return return
endif endif
" Get tag list index of the specified file
let fidx = s:Tlist_Get_File_Index(a:filename)
if fidx == -1
" File not present in the taglist window
return
endif
" Save the original window number " Save the original window number
let org_winnr = winnr() let org_winnr = winnr()
if org_winnr == winnum if org_winnr == winnum
@ -3860,21 +3858,26 @@ function! s:Tlist_Window_Close_File_Fold(filename)
let in_taglist_window = 0 let in_taglist_window = 0
endif endif
if in_taglist_window
" When entering the taglist window, no need to update the folds
return
endif
" Go to the taglist window " Go to the taglist window
if !in_taglist_window if !in_taglist_window
call s:Tlist_Exe_Cmd_No_Acmds(winnum . 'wincmd w') call s:Tlist_Exe_Cmd_No_Acmds(winnum . 'wincmd w')
endif endif
" Save the cursor position " Close all the folds
let save_lnum = line('.') silent! %foldclose
" Perform the requested action on the file " Get tag list index of the specified file
" Close the fold for the file let fidx = s:Tlist_Get_File_Index(a:filename)
exe "silent! " . s:tlist_{fidx}_start . "," . if fidx != -1
\ s:tlist_{fidx}_end . "foldclose" " Open the fold for the file
exe "silent! " . s:tlist_{fidx}_start . "," .
" Move the cursor to the original location \ s:tlist_{fidx}_end . "foldopen"
exe save_lnum endif
" Go back to the original window " Go back to the original window
if !in_taglist_window if !in_taglist_window