Skip to content

Commit f6acb27

Browse files
committed
Merge pull request #12: Correctly handle Windows paths without drive letter
2 parents e3f28a7 + b19202b commit f6acb27

File tree

4 files changed

+15
-7
lines changed

4 files changed

+15
-7
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ from the source code of the miscellaneous scripts using the Python module
3838
<!-- Start of generated documentation -->
3939

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

4343
### Asynchronous Vim script evaluation
4444

autoload/xolox/misc.vim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
" The version of my miscellaneous scripts.
22
"
33
" Author: Peter Odding <[email protected]>
4-
" Last Change: July 6, 2014
4+
" Last Change: July 7, 2014
55
" URL: http://peterodding.com/code/vim/misc/
66

7-
let g:xolox#misc#version = '1.14'
7+
let g:xolox#misc#version = '1.14.1'

autoload/xolox/misc/path.vim

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
" Pathname manipulation functions.
22
"
33
" Author: Peter Odding <[email protected]>
4-
" Last Change: July 6, 2014
4+
" Last Change: July 7, 2014
55
" URL: http://peterodding.com/code/vim/misc/
66

77
let s:windows_compatible = xolox#misc#os#is_win()
@@ -72,8 +72,12 @@ function! xolox#misc#path#split(path) " {{{1
7272
" UNC pathname.
7373
return split(a:path, '\%>2c[\/]\+')
7474
else
75-
" If it's not a UNC path we can simply split on slashes & backslashes.
76-
return split(a:path, '[\/]\+')
75+
" If it's not a UNC pathname we can simply split on slashes and
76+
" backslashes, although we should preserve a leading slash (which
77+
" denotes a pathname that is 'absolute to the current drive').
78+
let absolute = (a:path =~ '^[\/]')
79+
let segments = split(a:path, '[\/]\+')
80+
return absolute ? insert(segments, a:path[0]) : segments
7781
endif
7882
else
7983
" Everything else is treated as UNIX.
@@ -135,6 +139,10 @@ function! xolox#misc#path#absolute(path) " {{{1
135139
" Also normalize the two leading "directory separators" (I'm not
136140
" sure what else to call them :-) in Windows UNC pathnames.
137141
let parts[0] = repeat(xolox#misc#path#directory_separator(), 2) . parts[0][2:]
142+
elseif s:windows_compatible && parts[0] =~ '^[\/]$'
143+
" If a pathname is relative to the current drive we should add
144+
" the drive letter in order to make the pathname absolute.
145+
let parts[0] = matchstr(getcwd(), '^\a:')
138146
endif
139147
return xolox#misc#path#join(parts)
140148
endif

doc/misc.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ from the source code of the miscellaneous scripts using the Python module
168168
'vimdoctool.py' included in vim-tools [5].
169169

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

173173
-------------------------------------------------------------------------------
174174
*misc-asynchronous-vim-script-evaluation*

0 commit comments

Comments
 (0)