mirror of
https://github.com/preservim/nerdtree.git
synced 2024-10-18 13:50:21 +03:00
Add s:Path.Resolve function to address trailing slash issues.
The core issue is that in some versions of vim resolve() will remove trailing
slashes, while in others it will not. This lead to commit
bc745b6e99
attempting to address a double slash
problem. However, that broke symlink detection on systems where resolve()
removes trailing slashes. This new function just calls vim's resolve()
function, but removes trailing slashes if they exist.
This commit is contained in:
parent
6d0183ea78
commit
ba74b99fd7
@ -2521,6 +2521,16 @@ function! s:Path.Slash()
|
|||||||
return s:running_windows ? '\' : '/'
|
return s:running_windows ? '\' : '/'
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
"FUNCTION: Path.Resolve() {{{3
|
||||||
|
"Invoke the vim resolve() function and return the result
|
||||||
|
"This is necessary because in some versions of vim resolve() removes trailing
|
||||||
|
"slashes while in other versions it doesn't. This always removes the trailing
|
||||||
|
"slash
|
||||||
|
function! s:Path.Resolve(path)
|
||||||
|
let tmp = resolve(a:path)
|
||||||
|
return tmp =~# '/$' ? substitute(tmp, '/$', '', '') : tmp
|
||||||
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: Path.readInfoFromDisk(fullpath) {{{3
|
"FUNCTION: Path.readInfoFromDisk(fullpath) {{{3
|
||||||
"
|
"
|
||||||
"
|
"
|
||||||
@ -2555,12 +2565,12 @@ function! s:Path.readInfoFromDisk(fullpath)
|
|||||||
let lastPathComponent = self.getLastPathComponent(0)
|
let lastPathComponent = self.getLastPathComponent(0)
|
||||||
|
|
||||||
"get the path to the new node with the parent dir fully resolved
|
"get the path to the new node with the parent dir fully resolved
|
||||||
let hardPath = resolve(self.strTrunk()) . '/' . lastPathComponent
|
let hardPath = s:Path.Resolve(self.strTrunk()) . '/' . lastPathComponent
|
||||||
|
|
||||||
"if the last part of the path is a symlink then flag it as such
|
"if the last part of the path is a symlink then flag it as such
|
||||||
let self.isSymLink = (resolve(hardPath) != hardPath)
|
let self.isSymLink = (s:Path.Resolve(hardPath) != hardPath)
|
||||||
if self.isSymLink
|
if self.isSymLink
|
||||||
let self.symLinkDest = resolve(fullpath)
|
let self.symLinkDest = s:Path.Resolve(fullpath)
|
||||||
|
|
||||||
"if the link is a dir then slap a / on the end of its dest
|
"if the link is a dir then slap a / on the end of its dest
|
||||||
if isdirectory(self.symLinkDest)
|
if isdirectory(self.symLinkDest)
|
||||||
@ -2971,7 +2981,7 @@ function! s:initNerdTree(name)
|
|||||||
if dir =~# '^\.'
|
if dir =~# '^\.'
|
||||||
let dir = getcwd() . s:Path.Slash() . dir
|
let dir = getcwd() . s:Path.Slash() . dir
|
||||||
endif
|
endif
|
||||||
let dir = resolve(dir)
|
let dir = s:Path.Resolve(dir)
|
||||||
|
|
||||||
try
|
try
|
||||||
let path = s:Path.New(dir)
|
let path = s:Path.New(dir)
|
||||||
|
Loading…
Reference in New Issue
Block a user