Skip to content

Commit

Permalink
Merge pull request #110 from cperl82/fixes
Browse files Browse the repository at this point in the history
Symlinks Not Showing as Symlinks
  • Loading branch information
scrooloose committed Jan 11, 2012
2 parents 20f7ab8 + ba74b99 commit eced5f9
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions plugin/NERD_tree.vim
Original file line number Diff line number Diff line change
Expand Up @@ -2543,6 +2543,16 @@ function! s:Path.Slash()
return s:running_windows ? '\' : '/'
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
"
"
Expand Down Expand Up @@ -2577,12 +2587,12 @@ function! s:Path.readInfoFromDisk(fullpath)
let lastPathComponent = self.getLastPathComponent(0)

"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
let self.isSymLink = (resolve(hardPath) != hardPath)
let self.isSymLink = (s:Path.Resolve(hardPath) != hardPath)
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 isdirectory(self.symLinkDest)
Expand Down Expand Up @@ -2755,13 +2765,9 @@ function! s:Path._str()
endfunction

"FUNCTION: Path.strTrunk() {{{3
"Gets the path without the last segment on the end, always with an endslash
"Gets the path without the last segment on the end.
function! s:Path.strTrunk()
let toReturn = self.drive . '/' . join(self.pathSegments[0:-2], '/')
if toReturn !~# '\/$'
let toReturn .= '/'
endif
return toReturn
return self.drive . '/' . join(self.pathSegments[0:-2], '/')
endfunction

" FUNCTION: Path.tabnr() {{{3
Expand Down Expand Up @@ -2996,7 +3002,7 @@ function! s:initNerdTree(name)
if dir =~# '^\.'
let dir = getcwd() . s:Path.Slash() . dir
endif
let dir = resolve(dir)
let dir = s:Path.Resolve(dir)

try
let path = s:Path.New(dir)
Expand Down

0 comments on commit eced5f9

Please sign in to comment.