Skip to content

Commit

Permalink
Added support for windows network shares (\\box\share format paths)
Browse files Browse the repository at this point in the history
  • Loading branch information
actionshrimp committed Jul 7, 2011
1 parent 04aa45f commit 0b0c766
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions plugin/NERD_tree.vim
Original file line number Diff line number Diff line change
Expand Up @@ -1880,7 +1880,7 @@ let s:Path = {}
function! s:Path.AbsolutePathFor(str)
let prependCWD = 0
if s:running_windows
let prependCWD = a:str !~# '^.:\(\\\|\/\)'
let prependCWD = a:str !~# '^.:\(\\\|\/\)' && a:str !~# '^\(\\\\\|\/\/\)'
else
let prependCWD = a:str !~# '^/'
endif
Expand Down Expand Up @@ -2109,7 +2109,12 @@ endfunction
"If running windows, cache the drive letter for this path
function! s:Path.extractDriveLetter(fullpath)
if s:running_windows
let self.drive = substitute(a:fullpath, '\(^[a-zA-Z]:\).*', '\1', '')
if a:fullpath =~ '^\(\\\\\|\/\/\)'
let self.drive = substitute(a:fullpath, '^\(\(\\\\\|\/\/\)[^\\\/]*\(\\\|\/\)[^\\\/]*\).*', '\1', '')
let self.drive = substitute(self.drive, '/', '\', "g")
else
let self.drive = substitute(a:fullpath, '\(^[a-zA-Z]:\).*', '\1', '')
endif
else
let self.drive = ''
endif
Expand Down Expand Up @@ -2489,6 +2494,9 @@ function! s:Path.WinToUnixPath(pathstr)
"remove the x:\ of the front
let toReturn = substitute(toReturn, '^.*:\(\\\|/\)\?', '/', "")

"remove the \\ network share from the front
let toReturn = substitute(toReturn, '^\(\\\\\|\/\/\)[^\\\/]*\(\\\|\/\)[^\\\/]*\(\\\|\/\)\?', '/', "")

"convert all \ chars to /
let toReturn = substitute(toReturn, '\', '/', "g")

Expand Down Expand Up @@ -4114,4 +4122,4 @@ endfunction
"reset &cpo back to users setting
let &cpo = s:old_cpo

" vim: set sw=4 sts=4 et fdm=marker:
" vim: set sw=4 sts=4 et fdm=marker:

0 comments on commit 0b0c766

Please sign in to comment.