Merge branch 'update_reuse_option'
This commit is contained in:
commit
a87b1bf3c5
@ -93,13 +93,13 @@ endfunction
|
|||||||
"FUNCTION: s:activateDirNode() {{{1
|
"FUNCTION: s:activateDirNode() {{{1
|
||||||
"handle the user activating a tree node
|
"handle the user activating a tree node
|
||||||
function! s:activateDirNode(node)
|
function! s:activateDirNode(node)
|
||||||
call a:node.activate({'reuse': 1})
|
call a:node.activate()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: s:activateFileNode() {{{1
|
"FUNCTION: s:activateFileNode() {{{1
|
||||||
"handle the user activating a tree node
|
"handle the user activating a tree node
|
||||||
function! s:activateFileNode(node)
|
function! s:activateFileNode(node)
|
||||||
call a:node.activate({'reuse': 1, 'where': 'p'})
|
call a:node.activate({'reuse': 'all', 'where': 'p'})
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: s:activateBookmark() {{{1
|
"FUNCTION: s:activateBookmark() {{{1
|
||||||
@ -324,7 +324,7 @@ function! s:handleLeftClick()
|
|||||||
if currentNode.path.isDirectory
|
if currentNode.path.isDirectory
|
||||||
call currentNode.activate()
|
call currentNode.activate()
|
||||||
else
|
else
|
||||||
call currentNode.activate({'reuse': 1, 'where': 'p'})
|
call currentNode.activate({'reuse': 'all', 'where': 'p'})
|
||||||
endif
|
endif
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
@ -131,7 +131,8 @@ endfunction
|
|||||||
" 'where': Specifies whether the node should be opened in new split/tab or in
|
" 'where': Specifies whether the node should be opened in new split/tab or in
|
||||||
" the previous window. Can be either 'v' or 'h' or 't' (for open in
|
" the previous window. Can be either 'v' or 'h' or 't' (for open in
|
||||||
" new tab)
|
" new tab)
|
||||||
" 'reuse': if a window is displaying the file then jump the cursor there
|
" 'reuse': if a window is displaying the file then jump the cursor there. Can
|
||||||
|
" 'all', 'currenttab' or empty to not reuse.
|
||||||
" 'keepopen': dont close the tree window
|
" 'keepopen': dont close the tree window
|
||||||
" 'stay': open the file, but keep the cursor in the tree win
|
" 'stay': open the file, but keep the cursor in the tree win
|
||||||
function! s:Opener.New(path, opts)
|
function! s:Opener.New(path, opts)
|
||||||
@ -139,7 +140,13 @@ function! s:Opener.New(path, opts)
|
|||||||
|
|
||||||
let newObj._path = a:path
|
let newObj._path = a:path
|
||||||
let newObj._stay = nerdtree#has_opt(a:opts, 'stay')
|
let newObj._stay = nerdtree#has_opt(a:opts, 'stay')
|
||||||
let newObj._reuse = nerdtree#has_opt(a:opts, 'reuse')
|
|
||||||
|
if has_key(a:opts, 'reuse')
|
||||||
|
let newObj._reuse = a:opts['reuse']
|
||||||
|
else
|
||||||
|
let newObj._reuse = ''
|
||||||
|
endif
|
||||||
|
|
||||||
let newObj._keepopen = nerdtree#has_opt(a:opts, 'keepopen')
|
let newObj._keepopen = nerdtree#has_opt(a:opts, 'keepopen')
|
||||||
let newObj._where = has_key(a:opts, 'where') ? a:opts['where'] : ''
|
let newObj._where = has_key(a:opts, 'where') ? a:opts['where'] : ''
|
||||||
let newObj._treetype = b:NERDTreeType
|
let newObj._treetype = b:NERDTreeType
|
||||||
@ -235,7 +242,7 @@ endfunction
|
|||||||
|
|
||||||
"FUNCTION: Opener._openFile() {{{1
|
"FUNCTION: Opener._openFile() {{{1
|
||||||
function! s:Opener._openFile()
|
function! s:Opener._openFile()
|
||||||
if self._reuse && self._reuseWindow()
|
if self._reuseWindow()
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@ -307,13 +314,22 @@ endfunction
|
|||||||
"
|
"
|
||||||
"return 1 if we were successful
|
"return 1 if we were successful
|
||||||
function! s:Opener._reuseWindow()
|
function! s:Opener._reuseWindow()
|
||||||
|
if empty(self._reuse)
|
||||||
|
return 0
|
||||||
|
endif
|
||||||
|
|
||||||
"check the current tab for the window
|
"check the current tab for the window
|
||||||
let winnr = bufwinnr('^' . self._path.str() . '$')
|
let winnr = bufwinnr('^' . self._path.str() . '$')
|
||||||
if winnr != -1
|
if winnr != -1
|
||||||
call nerdtree#exec(winnr . "wincmd w")
|
call nerdtree#exec(winnr . "wincmd w")
|
||||||
call self._checkToCloseTree(0)
|
call self._checkToCloseTree(0)
|
||||||
return 1
|
return 1
|
||||||
else
|
endif
|
||||||
|
|
||||||
|
if self._reuse == 'currenttab'
|
||||||
|
return 0
|
||||||
|
endif
|
||||||
|
|
||||||
"check other tabs
|
"check other tabs
|
||||||
let tabnr = self._path.tabnr()
|
let tabnr = self._path.tabnr()
|
||||||
if tabnr
|
if tabnr
|
||||||
@ -323,7 +339,7 @@ function! s:Opener._reuseWindow()
|
|||||||
call nerdtree#exec(winnr . "wincmd w")
|
call nerdtree#exec(winnr . "wincmd w")
|
||||||
return 1
|
return 1
|
||||||
endif
|
endif
|
||||||
endif
|
|
||||||
return 0
|
return 0
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user