commit 402fea69023394f4c3f281f509d352612de22cf2 parent 589036f5c9b4dfe0761bf02a5bb7b9571099d95d Author: Martin Grenfell <martin_grenfell@msn.com> Date: Wed, 17 Dec 2008 20:21:06 +1300 make the NERDTreeMirror handler smarter Diffstat:
| M | plugin/NERD_tree.vim | | | 30 | +++++++++++++++++++----------- |
1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim @@ -1817,19 +1817,27 @@ function! s:initNerdTreeMirror() let trees[treeRoot.path.strForOS(0)] = i endfor - let options = insert(keys(trees), 'Select a tree to mirror:', 0) - let i = 1 - while i < len(options) - let options[i] = i . ' ' . options[i] - let i += 1 - endwhile - let choice = inputlist(options) + let bufferName = '' + if len(keys(trees)) > 1 + let options = insert(keys(trees), 'Select a tree to mirror:', 0) + let i = 1 + while i < len(options) + let options[i] = i . ' ' . options[i] + let i += 1 + endwhile - if choice < 1 || choice > len(options) - throw "NERDTree.InvalidInput" - endif + let choice = inputlist(options) - let bufferName = trees[keys(trees)[choice-1]] + if choice < 1 || choice > len(options) || choice == '' + return + endif + + let bufferName = trees[keys(trees)[choice-1]] + elseif len(keys(trees)) == 1 + let bufferName = values(trees)[0] + else + return s:initNerdTree('') + endif if s:treeExistsForTab() if s:isTreeOpen()
