Skip to content

Commit 8762e9e

Browse files
committed
System.Filepath: fix completeslash opt handling
1 parent 4ed9ac4 commit 8762e9e

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

autoload/vital/__vital__/System/Filepath.vim

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ let s:is_cygwin = has('win32unix')
1515
let s:is_mac = !s:is_windows && !s:is_cygwin
1616
\ && (has('mac') || has('macunix') || has('gui_macvim') ||
1717
\ (!isdirectory('/proc') && executable('sw_vers')))
18+
" windows expand follow do not need for file extention
1819
let s:is_case_tolerant = filereadable(expand('<sfile>:r') . '.VIM')
1920

2021
if s:is_windows
@@ -203,8 +204,8 @@ function! s:expand_home(path) abort
203204
endif
204205
let post_home_idx = match(a:path, s:path_sep_pattern)
205206
return post_home_idx is# -1
206-
\ ? s:remove_last_separator(expand(a:path))
207-
\ : s:remove_last_separator(expand(a:path[0 : post_home_idx - 1]))
207+
\ ? s:remove_last_separator(s:expand(a:path))
208+
\ : s:remove_last_separator(s:expand(a:path[0 : post_home_idx - 1]))
208209
\ . a:path[post_home_idx :]
209210
endfunction
210211

@@ -279,6 +280,22 @@ function! s:contains(path, base) abort
279280
return pathlist[: baselistlen - 1] ==# baselist
280281
endfunction
281282

283+
if s:is_windows && exists('&completeslash')
284+
function! s:expand(path) abort
285+
let backup_completeslash = &completeslash
286+
try
287+
set completeslash&
288+
return expand(a:path)
289+
finally
290+
let &completeslash = backup_completeslash
291+
endtry
292+
endfunction
293+
else
294+
function! s:expand(path) abort
295+
return expand(a:path)
296+
endfunction
297+
endif
298+
282299
let &cpo = s:save_cpo
283300
unlet s:save_cpo
284301

0 commit comments

Comments
 (0)