From dd754c7bc64f8802ab6ff660776e1dee0e0e2761 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Fri, 20 Nov 2015 19:16:07 +0000 Subject: [PATCH] add path.isAncestor --- lib/nerdtree/path.vim | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/nerdtree/path.vim b/lib/nerdtree/path.vim index f52426d..c83e36c 100644 --- a/lib/nerdtree/path.vim +++ b/lib/nerdtree/path.vim @@ -455,10 +455,22 @@ function! s:Path._ignorePatternMatches(pattern) return self.getLastPathComponent(0) =~# pat endfunction -"FUNCTION: Path.isUnder(path) {{{1 -"return 1 if this path is somewhere under the given path in the filesystem. +"FUNCTION: Path.isAncestor(path) {{{1 +"return 1 if this path is somewhere above the given path in the filesystem. " "a:path should be a dir +function! s:Path.isAncestor(path) + if !self.isDirectory + return 0 + endif + + let this = self.str() + let that = a:path.str() + return stridx(that, this) == 0 +endfunction + +"FUNCTION: Path.isUnder(path) {{{1 +"return 1 if this path is somewhere under the given path in the filesystem. function! s:Path.isUnder(path) if a:path.isDirectory == 0 return 0