Skip to content

Commit fe58d29

Browse files
committed
Support for mirrored NERDTree windows (issue #7)
1 parent a3ba9f6 commit fe58d29

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

autoload/xolox/session.vim

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
" Vim script
22
" Author: Peter Odding
3-
" Last Change: September 17, 2011
3+
" Last Change: September 18, 2011
44
" URL: http://peterodding.com/code/vim/session/
55

6-
let g:xolox#session#version = '1.4.13'
6+
let g:xolox#session#version = '1.4.14'
77

88
" Public API for session persistence. {{{1
99

@@ -113,6 +113,10 @@ function! s:state_filter(line)
113113
if a:line == 'normal zo'
114114
" Silence "E490: No fold found" errors.
115115
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
116120
else
117121
return a:line
118122
endif
@@ -122,13 +126,15 @@ function! xolox#session#save_special_windows(session) " {{{2
122126
" Integration between :mksession, :NERDTree and :Project.
123127
let tabpage = tabpagenr()
124128
let window = winnr()
129+
let s:nerdtrees = {}
125130
try
126131
if &sessionoptions =~ '\<tabpages\>'
127132
tabdo call s:check_special_tabpage(a:session)
128133
else
129134
call s:check_special_tabpage(a:session)
130135
endif
131136
finally
137+
unlet s:nerdtrees
132138
execute 'tabnext' tabpage
133139
execute window . 'wincmd w'
134140
call s:jump_to_window(a:session, tabpage, window)
@@ -145,8 +151,14 @@ endfunction
145151

146152
function! s:check_special_window(session)
147153
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
150162
elseif exists('g:proj_running') && g:proj_running == bufnr('%')
151163
let command = 'Project'
152164
let argument = expand('%:p')

0 commit comments

Comments
 (0)