mirror of
https://github.com/preservim/nerdtree.git
synced 2025-11-09 03:43:50 -05:00
Merge pull request #710 from jason0x43/globPath-fix
Handle non-relative globDir properly in Windows
This commit is contained in:
@@ -206,6 +206,25 @@ function! s:TreeDirNode.getDirChildren()
|
|||||||
return filter(self.children, 'v:val.path.isDirectory == 1')
|
return filter(self.children, 'v:val.path.isDirectory == 1')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
"FUNCTION: TreeDirNode._getGlobDir() {{{1
|
||||||
|
"Return a string giving the pathname related to this TreeDirNode. The returned
|
||||||
|
"pathname is in a glob-friendly format and is relative to the current working
|
||||||
|
"directory, if this TreeDirNode's path is under the current working directory.
|
||||||
|
function! s:TreeDirNode._getGlobDir()
|
||||||
|
" Gets a relative path, if possible. This ensures that 'wildignore' rules
|
||||||
|
" for relative paths will be obeyed.
|
||||||
|
let l:globDir = fnamemodify(self.path.str({'format': 'Glob'}), ':.')
|
||||||
|
|
||||||
|
" Calling fnamemodify() with ':.' on Windows systems strips the leading
|
||||||
|
" drive letter from paths that aren't under the working directory. Here,
|
||||||
|
" the drive letter is added back to the pathname.
|
||||||
|
if nerdtree#runningWindows() && l:globDir[0] == '\'
|
||||||
|
let l:globDir = self.path.drive . l:globDir
|
||||||
|
endif
|
||||||
|
|
||||||
|
return l:globDir
|
||||||
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: TreeDirNode.GetSelected() {{{1
|
"FUNCTION: TreeDirNode.GetSelected() {{{1
|
||||||
"Returns the current node if it is a dir node, or else returns the current
|
"Returns the current node if it is a dir node, or else returns the current
|
||||||
"nodes parent
|
"nodes parent
|
||||||
@@ -271,10 +290,7 @@ function! s:TreeDirNode._initChildren(silent)
|
|||||||
let self.children = []
|
let self.children = []
|
||||||
|
|
||||||
"get an array of all the files in the nodes dir
|
"get an array of all the files in the nodes dir
|
||||||
let dir = self.path
|
let globDir = self._getGlobDir()
|
||||||
|
|
||||||
"use a relative globDir so that relative wildignore rules will be obeyed
|
|
||||||
let globDir = fnamemodify(dir.str({'format': 'Glob'}), ':.')
|
|
||||||
|
|
||||||
if version >= 703
|
if version >= 703
|
||||||
let filesStr = globpath(globDir, '*', !g:NERDTreeRespectWildIgnore) . "\n" . globpath(globDir, '.*', !g:NERDTreeRespectWildIgnore)
|
let filesStr = globpath(globDir, '*', !g:NERDTreeRespectWildIgnore) . "\n" . globpath(globDir, '.*', !g:NERDTreeRespectWildIgnore)
|
||||||
@@ -446,8 +462,7 @@ function! s:TreeDirNode.refresh()
|
|||||||
"go thru all the files/dirs under this node
|
"go thru all the files/dirs under this node
|
||||||
let newChildNodes = []
|
let newChildNodes = []
|
||||||
let invalidFilesFound = 0
|
let invalidFilesFound = 0
|
||||||
let dir = self.path
|
let globDir = self._getGlobDir()
|
||||||
let globDir = fnamemodify(dir.str({'format': 'Glob'}), ':.')
|
|
||||||
let filesStr = globpath(globDir, '*') . "\n" . globpath(globDir, '.*')
|
let filesStr = globpath(globDir, '*') . "\n" . globpath(globDir, '.*')
|
||||||
let files = split(filesStr, "\n")
|
let files = split(filesStr, "\n")
|
||||||
for i in files
|
for i in files
|
||||||
|
|||||||
Reference in New Issue
Block a user