refactor option checking to simplify and remove duplication
This commit is contained in:
parent
b16a663618
commit
4425627683
@ -399,7 +399,7 @@ function! s:Bookmark.openInNewTab(options)
|
|||||||
exec "tabedit " . self.path.str({'format': 'Edit'})
|
exec "tabedit " . self.path.str({'format': 'Edit'})
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if has_key(a:options, 'stayInCurrentTab') && a:options['stayInCurrentTab']
|
if s:has_opt(a:options, 'stayInCurrentTab')
|
||||||
exec "tabnext " . currentTab
|
exec "tabnext " . currentTab
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
@ -1341,13 +1341,13 @@ endfunction
|
|||||||
function! s:TreeFileNode.openInNewTab(options)
|
function! s:TreeFileNode.openInNewTab(options)
|
||||||
let currentTab = tabpagenr()
|
let currentTab = tabpagenr()
|
||||||
|
|
||||||
if !has_key(a:options, 'keepTreeOpen')
|
if !s:has_opt(a:options, 'keepTreeOpen')
|
||||||
call s:closeTreeIfQuitOnOpen()
|
call s:closeTreeIfQuitOnOpen()
|
||||||
endif
|
endif
|
||||||
|
|
||||||
exec "tabedit " . self.path.str({'format': 'Edit'})
|
exec "tabedit " . self.path.str({'format': 'Edit'})
|
||||||
|
|
||||||
if has_key(a:options, 'stayInCurrentTab') && a:options['stayInCurrentTab']
|
if s:has_opt(a:options, 'stayInCurrentTab')
|
||||||
exec "tabnext " . currentTab
|
exec "tabnext " . currentTab
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@ -1803,14 +1803,14 @@ unlet s:TreeDirNode.openInNewTab
|
|||||||
function! s:TreeDirNode.openInNewTab(options)
|
function! s:TreeDirNode.openInNewTab(options)
|
||||||
let currentTab = tabpagenr()
|
let currentTab = tabpagenr()
|
||||||
|
|
||||||
if !has_key(a:options, 'keepTreeOpen') || !a:options['keepTreeOpen']
|
if !s:has_opt(a:options, 'keepTreeOpen')
|
||||||
call s:closeTreeIfQuitOnOpen()
|
call s:closeTreeIfQuitOnOpen()
|
||||||
endif
|
endif
|
||||||
|
|
||||||
tabnew
|
tabnew
|
||||||
call s:initNerdTree(self.path.str())
|
call s:initNerdTree(self.path.str())
|
||||||
|
|
||||||
if has_key(a:options, 'stayInCurrentTab') && a:options['stayInCurrentTab']
|
if s:has_opt(a:options, 'stayInCurrentTab')
|
||||||
exec "tabnext " . currentTab
|
exec "tabnext " . currentTab
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
@ -2482,7 +2482,7 @@ function! s:Path.str(...)
|
|||||||
let toReturn = self._str()
|
let toReturn = self._str()
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if has_key(options, 'escape') && options['escape']
|
if s:has_opt(options, 'escape')
|
||||||
let toReturn = shellescape(toReturn)
|
let toReturn = shellescape(toReturn)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@ -2686,6 +2686,12 @@ function! s:findAndRevealPath()
|
|||||||
call s:putCursorInTreeWin()
|
call s:putCursorInTreeWin()
|
||||||
call b:NERDTreeRoot.reveal(p)
|
call b:NERDTreeRoot.reveal(p)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
" FUNCTION: s:has_opt(options, name) {{{2
|
||||||
|
function! s:has_opt(options, name)
|
||||||
|
return has_key(a:options, a:name) && a:options[a:name] == 1
|
||||||
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: s:initNerdTree(name) {{{2
|
"FUNCTION: s:initNerdTree(name) {{{2
|
||||||
"Initialise the nerd tree for this tab. The tree will start in either the
|
"Initialise the nerd tree for this tab. The tree will start in either the
|
||||||
"given directory, or the directory associated with the given bookmark
|
"given directory, or the directory associated with the given bookmark
|
||||||
|
Loading…
Reference in New Issue
Block a user