runtime(netrw): upstream snapshot of v181 Commit: https://github.com/vim/vim/commit/d1a975ae6418b391088ba11aa85e00b6ab0db80a Author: Luca Saccarola <github.e4...@aleeas.com> Date: Sat Jun 7 17:35:18 2025 +0200
runtime(netrw): upstream snapshot of v181 closes: https://github.com/vim/vim/issues/17461 Signed-off-by: Luca Saccarola <github.e4...@aleeas.com> Signed-off-by: Christian Brabandt <c...@256bit.org> diff --git a/runtime/doc/pi_netrw.txt b/runtime/doc/pi_netrw.txt index 00799911e..ad5bc2d9b 100644 --- a/runtime/doc/pi_netrw.txt +++ b/runtime/doc/pi_netrw.txt @@ -2557,12 +2557,6 @@ your browsing preferences. (see also: |netrw-settings|) |g:netrw_maxfilenamelen|, which affects local file long listing. - *g:netrw_errorlvl* =0: error levels greater than or equal to - this are permitted to be displayed - 0: notes - 1: warnings - 2: errors - *g:netrw_fastbrowse* =0: slow speed directory browsing; never re-uses directory listings; always obtains directory listings. diff --git a/runtime/doc/tags b/runtime/doc/tags index 095570915..afa4a058f 100644 --- a/runtime/doc/tags +++ b/runtime/doc/tags @@ -7720,7 +7720,6 @@ g:netrw_dav_cmd pi_netrw.txt /*g:netrw_dav_cmd* g:netrw_decompress pi_netrw.txt /*g:netrw_decompress* g:netrw_dirhistmax pi_netrw.txt /*g:netrw_dirhistmax* g:netrw_dynamic_maxfilenamelen pi_netrw.txt /*g:netrw_dynamic_maxfilenamelen* -g:netrw_errorlvl pi_netrw.txt /*g:netrw_errorlvl* g:netrw_fastbrowse pi_netrw.txt /*g:netrw_fastbrowse* g:netrw_fetch_cmd pi_netrw.txt /*g:netrw_fetch_cmd* g:netrw_ffkeep pi_netrw.txt /*g:netrw_ffkeep* diff --git a/runtime/pack/dist/opt/netrw/autoload/netrw.vim b/runtime/pack/dist/opt/netrw/autoload/netrw.vim index 228f47063..0e019e10b 100644 --- a/runtime/pack/dist/opt/netrw/autoload/netrw.vim +++ b/runtime/pack/dist/opt/netrw/autoload/netrw.vim @@ -19,7 +19,7 @@ if &cp || exists("g:loaded_netrw") finish endif -let g:loaded_netrw = "v180" +let g:loaded_netrw = "v181" if !has("patch-9.1.1054") && !has('nvim') echoerr 'netrw needs Vim v9.1.1054' @@ -46,39 +46,10 @@ setl cpo&vim " (this function can optionally take a list of messages) " Mar 03, 2025 : max errnum currently is 107 function! netrw#ErrorMsg(level, msg, errnum) - if a:level < g:netrw_errorlvl - return - endif - - if a:level == 1 - let level = "**warning** (netrw) " - elseif a:level == 2 - let level = "**error** (netrw) " - else - let level = "**note** (netrw) " - endif - if has('nvim') - call v:lua.vim.notify(level . a:msg, a:level + 2) + call v:lua.vim.notify(a:msg, a:level + 2) else - " (optional) netrw will show messages using echomsg. Even if the - " message doesn't appear, at least it'll be recallable via :messages - " redraw! - if a:level == s:WARNING - echohl WarningMsg - elseif a:level == s:ERROR - echohl ErrorMsg - endif - - if type(a:msg) == 3 - for msg in a:msg - echomsg level.msg - endfor - else - echomsg level.a:msg - endif - - echohl None + call netrw#msg#Notify(a:level, a:msg) endif endfunction @@ -114,7 +85,7 @@ endif let s:NOTE = 0 let s:WARNING = 1 let s:ERROR = 2 -call s:NetrwInit("g:netrw_errorlvl", s:NOTE) +let g:_netrw_log = {'NOTE': 0, 'WARN': 1, 'ERROR': 2} let s:has_balloon = !has('nvim') && \ has("balloon_eval") && @@ -325,42 +296,31 @@ if exists("g:netrw_local_copycmd") let g:netrw_localcopycmd= g:netrw_local_copycmd call netrw#ErrorMsg(s:NOTE,"g:netrw_local_copycmd is deprecated in favor of g:netrw_localcopycmd",84) endif + if !exists("g:netrw_localcmdshell") let g:netrw_localcmdshell= "" endif + if !exists("g:netrw_localcopycmd") - if has("win32") - if g:netrw_cygwin - let g:netrw_localcopycmd= "cp" - else - let g:netrw_localcopycmd = expand("$COMSPEC", v:true) - call s:NetrwInit("g:netrw_localcopycmdopt"," /c copy") + let g:netrw_localcopycmd = 'cp' + let g:netrw_localcopycmdopt = '' + + if has("win32") && !g:netrw_cygwin + let g:netrw_localcopycmd = expand("$COMSPEC", v:true) + let g:netrw_localcopycmdopt = '/c copy' endif - elseif has("unix") || has("macunix") - let g:netrw_localcopycmd= "cp" - else - let g:netrw_localcopycmd= "" - endif endif + if !exists("g:netrw_localcopydircmd") - if has("win32") - if g:netrw_cygwin - let g:netrw_localcopydircmd = "cp" - call s:NetrwInit("g:netrw_localcopydircmdopt"," -R") - else - let g:netrw_localcopydircmd = expand("$COMSPEC", v:true) - call s:NetrwInit("g:netrw_localcopydircmdopt"," /c xcopy /e /c /h /i /k") - endif - elseif has("unix") - let g:netrw_localcopydircmd = "cp" - call s:NetrwInit("g:netrw_localcopydircmdopt"," -R") - elseif has("macunix") - let g:netrw_localcopydircmd = "cp" - call s:NetrwInit("g:netrw_localcopydircmdopt"," -R") - else - let g:netrw_localcopydircmd= "" - endif + let g:netrw_localcopydircmd = 'cp' + let g:netrw_localcopydircmdopt = '-R' + + if has("win32") && !g:netrw_cygwin + let g:netrw_localcopydircmd = "cp" + call s:NetrwInit("g:netrw_localcopydircmdopt", "-R") + endif endif + if exists("g:netrw_local_mkdir") let g:netrw_localmkdir= g:netrw_local_mkdir call netrw#ErrorMsg(s:NOTE,"g:netrw_local_mkdir is deprecated in favor of g:netrw_localmkdir",87) @@ -6208,24 +6168,18 @@ fun! s:NetrwMarkFileCopy(islocal,...) " sanity check if !exists("s:netrwmarkfilelist_{curbufnr}") || empty(s:netrwmarkfilelist_{curbufnr}) NetrwKeepj call netrw#ErrorMsg(2,"there are no marked files in this window (:help netrw-mf)",66) - " call Dret("s:NetrwMarkFileCopy") return endif - " call Decho("sanity chk passed: s:netrwmarkfilelist_".curbufnr."<".string(s:netrwmarkfilelist_{curbufnr}),'~'.expand("<slnum>")) if !exists("s:netrwmftgt") NetrwKeepj call netrw#ErrorMsg(s:ERROR,"your marked file target is empty! (:help netrw-mt)",67) - " call Dret("s:NetrwMarkFileCopy 0") return 0 endif - " call Decho("sanity chk passed: s:netrwmftgt<".s:netrwmftgt.">",'~'.expand("<slnum>")) if a:islocal && s:netrwmftgt_islocal " Copy marked files, local directory to local directory - " call Decho("copy from local to local",'~'.expand("<slnum>")) if !executable(g:netrw_localcopycmd) call netrw#ErrorMsg(s:ERROR,"g:netrw_localcopycmd<".g:netrw_localcopycmd."> not executable on your system, aborting",91) - " call Dfunc("s:NetrwMarkFileMove : g:netrw_localcopycmd<".g:netrw_localcopycmd."> n/a!") return endif @@ -6233,17 +6187,14 @@ fun! s:NetrwMarkFileCopy(islocal,...) if simplify(s:netrwmftgt) ==# simplify(b:netrw_curdir) if len(s:netrwmarkfilelist_{bufnr('%')}) == 1 " only one marked file - " call Decho("case: only one marked file",'~'.expand("<slnum>")) let args = netrw#os#Escape(b:netrw_curdir.s:netrwmarkfilelist_{bufnr('%')}[0]) let oldname = s:netrwmarkfilelist_{bufnr('%')}[0] elseif a:0 == 1 - " call Decho("case: handling one input argument",'~'.expand("<slnum>")) " this happens when the next case was used to recursively call s:NetrwMarkFileCopy() let args = netrw#os#Escape(b:netrw_curdir.a:1) let oldname = a:1 else " copy multiple marked files inside the same directory - " call Decho("case: handling a multiple marked files",'~'.expand("<slnum>")) let s:recursive= 1 for oldname in s:netrwmarkfilelist_{bufnr("%")} let ret= s:NetrwMarkFileCopy(a:islocal,oldname) @@ -6253,59 +6204,49 @@ fun! s:NetrwMarkFileCopy(islocal,...) endfor unlet s:recursive call s:NetrwUnmarkList(curbufnr,curdir) - " call Dret("s:NetrwMarkFileCopy ".ret) return ret endif call inputsave() - let newname= input("Copy ".oldname." to : ",oldname,"file") + let newname= input(printf("Copy %s to: ", oldname), oldname, 'file') call inputrestore() - if newname == "" - " call Dret("s:NetrwMarkFileCopy 0") + + if empty(newname) return 0 endif - let args= netrw#os#Escape(oldname) + + let args = netrw#os#Escape(oldname) let tgt = netrw#os#Escape(s:netrwmftgt.'/'.newname) else - let args= join(map(deepcopy(s:netrwmarkfilelist_{bufnr('%')}),"netrw#os#Escape(b:netrw_curdir.\"/\".v:val)")) + let args = join(map(deepcopy(s:netrwmarkfilelist_{bufnr('%')}),"netrw#os#Escape(b:netrw_curdir.\"/\".v:val)")) let tgt = netrw#os#Escape(s:netrwmftgt) endif + if !g:netrw_cygwin && has("win32") - let args= substitute(args,'/','\','g') + let args = substitute(args,'/','\','g') let tgt = substitute(tgt, '/','\','g') endif + if args =~ "'" |let args= substitute(args,"'\(.*\)'",' ','')|endif if tgt =~ "'" |let tgt = substitute(tgt ,"'\(.*\)'",' ','')|endif if args =~ '//'|let args= substitute(args,'//','/','g')|endif if tgt =~ '//'|let tgt = substitute(tgt ,'//','/','g')|endif - " call Decho("args <".args.">",'~'.expand("<slnum>")) - " call Decho("tgt <".tgt.">",'~'.expand("<slnum>")) + + let copycmd = g:netrw_localcopycmd + let copycmdopt = g:netrw_localcopycmdopt + if isdirectory(s:NetrwFile(args)) - " call Decho("args<".args."> is a directory",'~'.expand("<slnum>")) - let copycmd= g:netrw_localcopydircmd - " call Decho("using copydircmd<".copycmd.">",'~'.expand("<slnum>")) - if !g:netrw_cygwin && has("win32") + let copycmd = g:netrw_localcopydircmd + let copycmdopt = g:netrw_localcopydircmdopt + if has('win32') && !g:netrw_cygwin " window's xcopy doesn't copy a directory to a target properly. Instead, it copies a directory's " contents to a target. One must append the source directory name to the target to get xcopy to " do the right thing. let tgt= tgt.'\'.substitute(a:1,'^.*[\/]','','') - " call Decho("modified tgt for xcopy",'~'.expand("<slnum>")) endif - else - let copycmd= g:netrw_localcopycmd endif - if g:netrw_localcopycmd =~ '\s' - let copycmd = substitute(copycmd,'\s.*$','','') - let copycmdargs = substitute(copycmd,'^.\{-}\(\s.*\)$',' ','') - let copycmd = netrw#fs#WinPath(copycmd).copycmdargs - else - let copycmd = netrw#fs#WinPath(copycmd) - endif - " call Decho("args <".args.">",'~'.expand("<slnum>")) - " call Decho("tgt <".tgt.">",'~'.expand("<slnum>")) - " call Decho("copycmd<".copycmd.">",'~'.expand("<slnum>")) - " call Decho("system(".copycmd." '".args."' '".tgt."')",'~'.expand("<slnum>")) - call system(copycmd.g:netrw_localcopycmdopt." '".args."' '".tgt."'") + + call system(printf("%s %s '%s' '%s'", copycmd, copycmdopt, args, tgt)) if v:shell_error != 0 if exists("b:netrw_curdir") && b:netrw_curdir != getcwd() && g:netrw_keepdir call netrw#ErrorMsg(s:ERROR,"copy failed; perhaps due to vim's current directory<".getcwd()."> not matching netrw's (".b:netrw_curdir.") (see :help netrw-cd)",101) diff --git a/runtime/pack/dist/opt/netrw/autoload/netrw/msg.vim b/runtime/pack/dist/opt/netrw/autoload/netrw/msg.vim index 75a5330e6..8144a45a3 100644 --- a/runtime/pack/dist/opt/netrw/autoload/netrw/msg.vim +++ b/runtime/pack/dist/opt/netrw/autoload/netrw/msg.vim @@ -27,4 +27,33 @@ function! netrw#msg#Deprecate(name, version, alternatives) call add(s:deprecation_msgs, a:name) endfunction +" netrw#msg#Notify: {{{ +" Usage: netrw#ErrorMsg(g:_netrw_log, 'some message') +" netrw#ErrorMsg(g:_netrw_log, ["message1","message2",...],error-number) +" (this function can optionally take a list of messages) +function! netrw#msg#Notify(level, msg) + if has('nvim') + call v:lua.vim.notify(level . a:msg, a:level + 2) + return + endif + + if a:level == g:_netrw_log.WARN + echohl WarningMsg + elseif a:level == g:_netrw_log.ERROR + echohl ErrorMsg + endif + + if type(a:msg) == v:t_list + for msg in a:msg + echomsg msg + endfor + else + echomsg a:msg + endif + + echohl None +endfunction + +" }}} + " vim:ts=8 sts=4 sw=4 et fdm=marker diff --git a/runtime/pack/dist/opt/netrw/autoload/netrw/os.vim b/runtime/pack/dist/opt/netrw/autoload/netrw/os.vim index 1ab1bd038..23d48e0d5 100644 --- a/runtime/pack/dist/opt/netrw/autoload/netrw/os.vim +++ b/runtime/pack/dist/opt/netrw/autoload/netrw/os.vim @@ -37,7 +37,7 @@ endfunction function! netrw#os#Open(file) abort if has('nvim') - call luaeval('vim.ui.open(_A[1]) and nil', [a:file]) + call luaeval('vim.ui.open(_A) and nil', a:file) else call dist#vim9#Open(a:file) endif diff --git a/runtime/pack/dist/opt/netrw/autoload/netrwSettings.vim b/runtime/pack/dist/opt/netrw/autoload/netrwSettings.vim index 20428d621..98e4b52cd 100644 --- a/runtime/pack/dist/opt/netrw/autoload/netrwSettings.vim +++ b/runtime/pack/dist/opt/netrw/autoload/netrwSettings.vim @@ -15,7 +15,7 @@ if &cp || exists("g:loaded_netrwSettings") finish endif -let g:loaded_netrwSettings = "v180" +let g:loaded_netrwSettings = "v181" " NetrwSettings: {{{ @@ -124,7 +124,6 @@ function! netrwSettings#NetrwSettings() put = '\" let g:netrw_dynamic_maxfilenamelen= (not defined)' endif put = 'let g:netrw_dirhistmax = '.g:netrw_dirhistmax - put = 'let g:netrw_errorlvl = '.g:netrw_errorlvl put = 'let g:netrw_fastbrowse = '.g:netrw_fastbrowse let fnameescline= line("$") put = 'let g:netrw_fname_escape = '.string(g:netrw_fname_escape) diff --git a/runtime/pack/dist/opt/netrw/doc/netrw.txt b/runtime/pack/dist/opt/netrw/doc/netrw.txt index 5655acffa..59d1a2e3a 100644 --- a/runtime/pack/dist/opt/netrw/doc/netrw.txt +++ b/runtime/pack/dist/opt/netrw/doc/netrw.txt @@ -2557,12 +2557,6 @@ your browsing preferences. (see also: |netrw-settings|) |g:netrw_maxfilenamelen|, which affects local file long listing. - *g:netrw_errorlvl* =0: error levels greater than or equal to - this are permitted to be displayed - 0: notes - 1: warnings - 2: errors - *g:netrw_fastbrowse* =0: slow speed directory browsing; never re-uses directory listings; always obtains directory listings. diff --git a/runtime/pack/dist/opt/netrw/plugin/netrwPlugin.vim b/runtime/pack/dist/opt/netrw/plugin/netrwPlugin.vim index 178eecc28..eaa97b8bc 100644 --- a/runtime/pack/dist/opt/netrw/plugin/netrwPlugin.vim +++ b/runtime/pack/dist/opt/netrw/plugin/netrwPlugin.vim @@ -15,7 +15,7 @@ if &cp || exists("g:loaded_netrwPlugin") finish endif -let g:loaded_netrwPlugin = "v180" +let g:loaded_netrwPlugin = "v181" let s:keepcpo = &cpo set cpo&vim -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscr...@googlegroups.com. To view this discussion visit https://groups.google.com/d/msgid/vim_dev/E1uNvjI-005fBU-Oq%40256bit.org.