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

View File

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