Skip to content

Commit

Permalink
Merge pull request #12: Correctly handle Windows paths without drive …
Browse files Browse the repository at this point in the history
…letter
  • Loading branch information
xolox committed Jul 7, 2014
2 parents e3f28a7 + b19202b commit f6acb27
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -38,7 +38,7 @@ from the source code of the miscellaneous scripts using the Python module
<!-- Start of generated documentation -->

The documentation of the 93 functions below was extracted from
19 Vim scripts on July 6, 2014 at 18:28.
19 Vim scripts on July 7, 2014 at 19:00.

### Asynchronous Vim script evaluation

Expand Down
4 changes: 2 additions & 2 deletions autoload/xolox/misc.vim
@@ -1,7 +1,7 @@
" The version of my miscellaneous scripts.
"
" Author: Peter Odding <peter@peterodding.com>
" Last Change: July 6, 2014
" Last Change: July 7, 2014
" URL: http://peterodding.com/code/vim/misc/

let g:xolox#misc#version = '1.14'
let g:xolox#misc#version = '1.14.1'
14 changes: 11 additions & 3 deletions autoload/xolox/misc/path.vim
@@ -1,7 +1,7 @@
" Pathname manipulation functions.
"
" Author: Peter Odding <peter@peterodding.com>
" Last Change: July 6, 2014
" Last Change: July 7, 2014
" URL: http://peterodding.com/code/vim/misc/

let s:windows_compatible = xolox#misc#os#is_win()
Expand Down Expand Up @@ -72,8 +72,12 @@ function! xolox#misc#path#split(path) " {{{1
" UNC pathname.
return split(a:path, '\%>2c[\/]\+')
else
" If it's not a UNC path we can simply split on slashes & backslashes.
return split(a:path, '[\/]\+')
" If it's not a UNC pathname we can simply split on slashes and
" backslashes, although we should preserve a leading slash (which
" denotes a pathname that is 'absolute to the current drive').
let absolute = (a:path =~ '^[\/]')
let segments = split(a:path, '[\/]\+')
return absolute ? insert(segments, a:path[0]) : segments
endif
else
" Everything else is treated as UNIX.
Expand Down Expand Up @@ -135,6 +139,10 @@ function! xolox#misc#path#absolute(path) " {{{1
" Also normalize the two leading "directory separators" (I'm not
" sure what else to call them :-) in Windows UNC pathnames.
let parts[0] = repeat(xolox#misc#path#directory_separator(), 2) . parts[0][2:]
elseif s:windows_compatible && parts[0] =~ '^[\/]$'
" If a pathname is relative to the current drive we should add
" the drive letter in order to make the pathname absolute.
let parts[0] = matchstr(getcwd(), '^\a:')
endif
return xolox#misc#path#join(parts)
endif
Expand Down
2 changes: 1 addition & 1 deletion doc/misc.txt
Expand Up @@ -168,7 +168,7 @@ from the source code of the miscellaneous scripts using the Python module
'vimdoctool.py' included in vim-tools [5].

The documentation of the 93 functions below was extracted from 19 Vim scripts
on July 6, 2014 at 18:28.
on July 7, 2014 at 19:00.

-------------------------------------------------------------------------------
*misc-asynchronous-vim-script-evaluation*
Expand Down

0 comments on commit f6acb27

Please sign in to comment.