nerdtree

A tree explorer plugin for vim.
Index Commits Files Refs
commit dd754c7bc64f8802ab6ff660776e1dee0e0e2761
parent 9eb0004278f1243245e10b1692215aad05ea273d
Author: Martin Grenfell <martin.grenfell@gmail.com>
Date:   Fri, 20 Nov 2015 19:16:07 +0000

add path.isAncestor

Diffstat:
Mlib/nerdtree/path.vim | 16++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git 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