add Path.isUnixHiddenFile and refactor to use it

This commit is contained in:
Martin Grenfell 2012-11-12 09:55:50 +00:00
parent 36cd8bfea7
commit 30a770aab0

@ -2486,6 +2486,13 @@ function! s:Path.getSortOrderIndex()
return s:NERDTreeSortStarIndex return s:NERDTreeSortStarIndex
endfunction endfunction
"FUNCTION: Path.isUnixHiddenFile() {{{3
"check for unix hidden files
function! s:Path.isUnixHiddenFile()
return self.getLastPathComponent(0) =~# '^\.'
endfunction
"FUNCTION: Path.ignore() {{{3 "FUNCTION: Path.ignore() {{{3
"returns true if this path should be ignored "returns true if this path should be ignored
function! s:Path.ignore() function! s:Path.ignore()
@ -2499,7 +2506,7 @@ function! s:Path.ignore()
endif endif
"dont show hidden files unless instructed to "dont show hidden files unless instructed to
if b:NERDTreeShowHidden ==# 0 && self.getLastPathComponent(0) =~# '^\.' if b:NERDTreeShowHidden ==# 0 && self.isUnixHiddenFile()
return 1 return 1
endif endif
@ -2999,7 +3006,7 @@ function! s:findAndRevealPath()
return return
endtry endtry
if p.getLastPathComponent(0) =~# '^\.' if p.isUnixHiddenFile()
let showhidden=g:NERDTreeShowHidden let showhidden=g:NERDTreeShowHidden
let g:NERDTreeShowHidden = 1 let g:NERDTreeShowHidden = 1
endif endif
@ -3029,7 +3036,7 @@ function! s:findAndRevealPath()
call s:putCursorInTreeWin() call s:putCursorInTreeWin()
call b:NERDTreeRoot.reveal(p) call b:NERDTreeRoot.reveal(p)
if p.getLastPathComponent(0) =~# '^\.' if p.isUnixHiddenFile()
let g:NERDTreeShowHidden = showhidden let g:NERDTreeShowHidden = showhidden
endif endif
endfunction endfunction