Implement the "isHiddenUnder()" method for Path

This commit is contained in:
Jason Franklin 2017-12-22 10:28:31 -05:00
parent 57788abd6f
commit 0ff697eb40
2 changed files with 24 additions and 11 deletions

View File

@ -277,11 +277,6 @@ function! s:findAndRevealPath(pathStr)
return
endtry
if l:pathObj.isUnixHiddenPath()
let l:showHidden = g:NERDTreeShowHidden
let g:NERDTreeShowHidden = 1
endif
if !g:NERDTree.ExistsForTab()
try
let l:cwd = g:NERDTreePath.New(getcwd())
@ -298,19 +293,18 @@ function! s:findAndRevealPath(pathStr)
else
NERDTreeFocus
if !l:pathObj.isUnder(g:NERDTreeFileNode.GetRootForTab().path)
call b:NERDTree.ui.setShowHidden(g:NERDTreeShowHidden)
if !l:pathObj.isUnder(b:NERDTree.root.path)
call s:chRoot(g:NERDTreeDirNode.New(l:pathObj.getParent(), b:NERDTree))
endif
endif
if l:pathObj.isHiddenUnder(b:NERDTree.root.path)
call b:NERDTree.ui.setShowHidden(1)
endif
let l:node = b:NERDTree.root.reveal(l:pathObj)
call b:NERDTree.render()
call l:node.putCursorHere(1, 0)
if l:pathObj.isUnixHiddenFile()
let g:NERDTreeShowHidden = l:showHidden
endif
endfunction
"FUNCTION: s:handleLeftClick() {{{1

View File

@ -405,6 +405,25 @@ function! s:Path.getSortKey()
return self._sortKey
endfunction
" FUNCTION: Path.isHiddenUnder(path) {{{1
function! s:Path.isHiddenUnder(path)
if !self.isUnder(a:path)
return 0
endif
let l:startIndex = len(a:path.pathSegments)
let l:segments = self.pathSegments[l:startIndex:]
for l:segment in l:segments
if l:segment =~# '^\.'
return 1
endif
endfor
return 0
endfunction
" FUNCTION: Path.isUnixHiddenFile() {{{1
" check for unix hidden files