1
1
" Vim script
2
2
" Author: Peter Odding
3
- " Last Change: September 17 , 2011
3
+ " Last Change: September 18 , 2011
4
4
" URL: http://peterodding.com/code/vim/session/
5
5
6
- let g: xolox #session#version = ' 1.4.13 '
6
+ let g: xolox #session#version = ' 1.4.14 '
7
7
8
8
" Public API for session persistence. {{{1
9
9
@@ -113,6 +113,10 @@ function! s:state_filter(line)
113
113
if a: line == ' normal zo'
114
114
" Silence "E490: No fold found" errors.
115
115
return ' silent! normal zo'
116
+ elseif a: line = ~ ' ^file .\{-}[\\/]NERD_tree_\d$'
117
+ " Silence "E95: Buffer with this name already exists" when restoring
118
+ " mirrored NERDTree windows.
119
+ return ' silent! ' . a: line
116
120
else
117
121
return a: line
118
122
endif
@@ -122,13 +126,15 @@ function! xolox#session#save_special_windows(session) " {{{2
122
126
" Integration between :mksession, :NERDTree and :Project.
123
127
let tabpage = tabpagenr ()
124
128
let window = winnr ()
129
+ let s: nerdtrees = {}
125
130
try
126
131
if &sessionoptions = ~ ' \<tabpages\>'
127
132
tabdo call s: check_special_tabpage (a: session )
128
133
else
129
134
call s: check_special_tabpage (a: session )
130
135
endif
131
136
finally
137
+ unlet s: nerdtrees
132
138
execute ' tabnext' tabpage
133
139
execute window . ' wincmd w'
134
140
call s: jump_to_window (a: session , tabpage, window )
@@ -145,8 +151,14 @@ endfunction
145
151
146
152
function ! s: check_special_window (session)
147
153
if exists (' b:NERDTreeRoot' )
148
- let command = ' NERDTree'
149
- let argument = b: NERDTreeRoot .path .str ()
154
+ if ! has_key (s: nerdtrees , bufnr (' %' ))
155
+ let command = ' NERDTree'
156
+ let argument = b: NERDTreeRoot .path .str ()
157
+ let s: nerdtrees [bufnr (' %' )] = 1
158
+ else
159
+ let command = ' NERDTreeMirror'
160
+ let argument = ' '
161
+ endif
150
162
elseif exists (' g:proj_running' ) && g: proj_running == bufnr (' %' )
151
163
let command = ' Project'
152
164
let argument = expand (' %:p' )
0 commit comments