runtime(tar): remove dependency on netrw#WinPath, include mapping doc
related: #17124
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/runtime/autoload/tar.vim b/runtime/autoload/tar.vim
index 4aab915..499036e 100644
--- a/runtime/autoload/tar.vim
+++ b/runtime/autoload/tar.vim
@@ -14,6 +14,7 @@
" 2025 Mar 02 by Vim Project: escape the filename before using :read
" 2025 Mar 02 by Vim Project: determine the compression using readblob()
" instead of shelling out to file(1)
+" 2025 Apr 16 by Vim Project: decouple from netrw by adding s:WinPath()
"
" Contains many ideas from Michael Toren's <tar.vim>
"
@@ -146,7 +147,7 @@
let lastline= line("$")
call setline(lastline+1,'" tar.vim version '.g:loaded_tar)
call setline(lastline+2,'" Browsing tarfile '.a:tarfile)
- call setline(lastline+3,'" Select a file with cursor and press ENTER')
+ call setline(lastline+3,'" Select a file with cursor and press ENTER, "x" to extract a file')
keepj $put =''
keepj sil! 0d
keepj $
@@ -615,7 +616,7 @@
let tarball = expand("%")
let tarbase = substitute(tarball,'\..*$','','')
- let extractcmd= netrw#WinPath(g:tar_extractcmd)
+ let extractcmd= s:WinPath(g:tar_extractcmd)
if filereadable(tarbase.".tar")
call system(extractcmd." ".shellescape(tarbase).".tar ".shellescape(fname))
if v:shell_error != 0
@@ -766,6 +767,25 @@
endfun
" ---------------------------------------------------------------------
+" s:WinPath: {{{2
+fun! s:WinPath(path)
+ if (!g:netrw_cygwin || &shell !~ '\%(\<bash\>\|\<zsh\>\)\%(\.exe\)\=$') && has("win32")
+ " remove cygdrive prefix, if present
+ let path = substitute(a:path, '/cygdrive/\(.\)', '\1:', '')
+ " remove trailing slash (Win95)
+ let path = substitute(path, '\(\\\|/\)$', '', 'g')
+ " remove escaped spaces
+ let path = substitute(path, '\ ', ' ', 'g')
+ " convert slashes to backslashes
+ let path = substitute(path, '/', '\', 'g')
+ else
+ let path = a:path
+ endif
+
+ return path
+endfun
+
+" ---------------------------------------------------------------------
" tar#Vimuntar: installs a tarball in the user's .vim / vimfiles directory {{{2
fun! tar#Vimuntar(...)
let tarball = expand("%")
@@ -786,7 +806,7 @@
if simplify(curdir) != simplify(vimhome)
" copy (possibly compressed) tarball to .vim/vimfiles
- call system(netrw#WinPath(g:tar_copycmd)." ".shellescape(tartail)." ".shellescape(vimhome))
+ call system(s:WinPath(g:tar_copycmd)." ".shellescape(tartail)." ".shellescape(vimhome))
exe "cd ".fnameescape(vimhome)
endif
@@ -808,7 +828,7 @@
else
call vimball#Decompress(tartail,0)
endif
- let extractcmd= netrw#WinPath(g:tar_extractcmd)
+ let extractcmd= s:WinPath(g:tar_extractcmd)
call system(extractcmd." ".shellescape(tarbase.".tar"))
" set up help