From e3f36377c156749bbdafc46d8a8cd017f378b4b5 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Sun, 23 Apr 2023 15:22:55 +0200 Subject: vim-patch:71badf9547e8 (#23285) Update runtime files https://github.com/vim/vim/commit/71badf9547e8f89571b9a095183671cbb333d528 Co-authored-by: Bram Moolenaar --- runtime/autoload/netrw.vim | 271 ++++++++++++++++++++++++++++++++------------- 1 file changed, 195 insertions(+), 76 deletions(-) (limited to 'runtime/autoload/netrw.vim') diff --git a/runtime/autoload/netrw.vim b/runtime/autoload/netrw.vim index 2fcf0b32c7..6c9938d8bb 100644 --- a/runtime/autoload/netrw.vim +++ b/runtime/autoload/netrw.vim @@ -1,7 +1,7 @@ " netrw.vim: Handles file transfer and remote directory listing across " AUTOLOAD SECTION -" Date: Aug 16, 2021 -" Version: 171 +" Date: Mar 15, 2023 +" Version: 172 " Maintainer: Charles E Campbell " GetLatestVimScripts: 1075 1 :AutoInstall: netrw.vim " Copyright: Copyright (C) 2016 Charles E. Campbell {{{1 @@ -43,7 +43,7 @@ if exists("s:needspatches") endfor endif -let g:loaded_netrw = "v171" +let g:loaded_netrw = "v172" if !exists("s:NOTE") let s:NOTE = 0 let s:WARNING = 1 @@ -208,7 +208,6 @@ let g:netrw_localcopycmdopt = "" let g:netrw_localcopydircmdopt = "" let g:netrw_localmkdiropt = "" let g:netrw_localmovecmdopt = "" -let g:netrw_localrmdiropt = "" " --------------------------------------------------------------------- " Default values for netrw's global protocol variables {{{2 @@ -1151,6 +1150,11 @@ endfun " --------------------------------------------------------------------- " netrw#Lexplore: toggle Explorer window, keeping it on the left of the current tab {{{2 +" Uses g:netrw_chgwin : specifies the window where Lexplore files are to be opened +" t:netrw_lexposn : winsaveview() output (used on Lexplore window) +" t:netrw_lexbufnr: the buffer number of the Lexplore buffer (internal to this function) +" s:lexplore_win : window number of Lexplore window (serves to indicate which window is a Lexplore window) +" w:lexplore_buf : buffer number of Lexplore window (serves to indicate which window is a Lexplore window) fun! netrw#Lexplore(count,rightside,...) " call Dfunc("netrw#Lexplore(count=".a:count." rightside=".a:rightside.",...) a:0=".a:0." ft=".&ft) let curwin= winnr() @@ -1167,6 +1171,8 @@ fun! netrw#Lexplore(count,rightside,...) " call Decho("exe Explore ".fnameescape(a:1),'~'.expand("")) exe "Explore ".fnameescape(a1) exe curwin."wincmd w" + let s:lexplore_win= curwin + let w:lexplore_buf= bufnr("%") if exists("t:netrw_lexposn") " call Decho("forgetting t:netrw_lexposn",'~'.expand("")) unlet t:netrw_lexposn @@ -1241,7 +1247,7 @@ fun! netrw#Lexplore(count,rightside,...) let t:netrw_lexbufnr = bufnr("%") " done to prevent build-up of hidden buffers due to quitting and re-invocation of :Lexplore. " Since the intended use of :Lexplore is to have an always-present explorer window, the extra - " effort to mis-use :Lex is warranted. + " effort to prevent mis-use of :Lex is warranted. set bh=wipe " call Decho("let t:netrw_lexbufnr=".t:netrw_lexbufnr) " call Decho("t:netrw_lexposn".(exists("t:netrw_lexposn")? string(t:netrw_lexposn) : " n/a")) @@ -1645,7 +1651,7 @@ fun! s:NetrwOptionsSave(vt) endif let {a:vt}netrw_fokeep = &l:fo " formatoptions let {a:vt}netrw_gdkeep = &l:gd " gdefault - let {a:vt}netrw_gokeep = &l:go " guioptions + let {a:vt}netrw_gokeep = &go " guioptions let {a:vt}netrw_hidkeep = &l:hidden let {a:vt}netrw_imkeep = &l:im let {a:vt}netrw_iskkeep = &l:isk @@ -1711,8 +1717,9 @@ fun! s:NetrwOptionsSafe(islocal) if &cpo =~ 'a' | call s:NetrwSetSafeSetting("&cpo",substitute(&cpo,'a','','g')) | endif if &cpo =~ 'A' | call s:NetrwSetSafeSetting("&cpo",substitute(&cpo,'A','','g')) | endif setl fo=nroql2 - " call s:NetrwSetSafeSetting("&go","begmr") - if &go =~ '\ca' | call s:NetrwSetSafeSetting("&go",substitute(&go,'\ca','','g')) | endif + if &go =~ 'a' | set go-=a | endif + if &go =~ 'A' | set go-=A | endif + if &go =~ 'P' | set go-=P | endif call s:NetrwSetSafeSetting("&l:hid",0) call s:NetrwSetSafeSetting("&l:im",0) setl isk+=@ isk+=* isk+=/ @@ -1751,11 +1758,13 @@ fun! s:NetrwOptionsRestore(vt) " call Decho("settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo." a:vt=".a:vt,'~'.expand("")) if !exists("{a:vt}netrw_optionsave") " call Decho("case ".a:vt."netrw_optionsave : doesn't exist",'~'.expand("")) - if !isdirectory(expand('%')) + if filereadable(expand("%")) " call Decho("..doing filetype detect anyway") - filetype detect + filetype detect +" call Decho("..settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo." a:vt=".a:vt,'~'.expand("")) + else + setl ft=netrw endif -" call Decho("..settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo." a:vt=".a:vt,'~'.expand("")) " call Decho("..ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)",'~'.expand("")) " call Dret("s:NetrwOptionsRestore : ".a:vt."netrw_optionsave doesn't exist") return @@ -1795,7 +1804,7 @@ fun! s:NetrwOptionsRestore(vt) " call Decho("(s:NetrwOptionsRestore) #4 lines=".&lines) call s:NetrwRestoreSetting(a:vt."netrw_fokeep" ,"&l:fo") call s:NetrwRestoreSetting(a:vt."netrw_gdkeep" ,"&l:gd") - call s:NetrwRestoreSetting(a:vt."netrw_gokeep" ,"&l:go") + call s:NetrwRestoreSetting(a:vt."netrw_gokeep" ,"&go") call s:NetrwRestoreSetting(a:vt."netrw_hidkeep" ,"&l:hidden") " call Decho("(s:NetrwOptionsRestore) #5 lines=".&lines) call s:NetrwRestoreSetting(a:vt."netrw_imkeep" ,"&l:im") @@ -1861,11 +1870,9 @@ fun! s:NetrwOptionsRestore(vt) " were having their filetype detect-generated settings overwritten by " NetrwOptionRestore. if &ft != "netrw" - if !isdirectory(expand('%')) -" call Decho("before: filetype detect (ft=".&ft.")",'~'.expand("")) - filetype detect -" call Decho("after : filetype detect (ft=".&ft.")",'~'.expand("")) - endif +" call Decho("before: filetype detect (ft=".&ft.")",'~'.expand("")) + filetype detect +" call Decho("after : filetype detect (ft=".&ft.")",'~'.expand("")) endif " call Decho("(s:NetrwOptionsRestore) lines=".&lines) " call Decho("settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo." a:vt=".a:vt,'~'.expand("")) @@ -2940,13 +2947,19 @@ fun! s:NetrwGetFile(readcmd, tfile, method) " rename buffer back to remote filename call s:NetrwBufRename(rfile) + " Jan 19, 2022: COMBAK -- bram problem with https://github.com/vim/vim/pull/9554.diff filetype " Detect filetype of local version of remote file. " Note that isk must not include a "/" for scripts.vim " to process this detection correctly. -" call Decho("detect filetype of local version of remote file",'~'.expand("")) - let iskkeep= &l:isk +" call Decho("detect filetype of local version of remote file<".rfile.">",'~'.expand("")) +" call Decho("..did_filetype()=".did_filetype()) + setl ft= +" call Decho("..initial filetype<".&ft."> for buf#".bufnr()."<".bufname().">") + let iskkeep= &isk setl isk-=/ - let &l:isk= iskkeep + filetype detect +" call Decho("..local filetype<".&ft."> for buf#".bufnr()."<".bufname().">") + let &isk= iskkeep " call Dredir("ls!","NetrwGetFile (renamed buffer back to remote filename<".rfile."> : expand(%)<".expand("%").">)") let line1 = 1 let line2 = line("$") @@ -4227,7 +4240,7 @@ fun! s:NetrwGetBuffer(islocal,dirname) endif " call Decho(" bufnum#".bufnum,'~'.expand("")) - " hijack the current buffer + " highjack the current buffer " IF the buffer already has the desired name " AND it is empty let curbuf = bufname("%") @@ -4235,7 +4248,7 @@ fun! s:NetrwGetBuffer(islocal,dirname) let curbuf = getcwd() endif " call Dredir("ls!","NetrwGetFile (renamed buffer back to remote filename<".rfile."> : expand(%)<".expand("%").">)") -" call Decho("deciding if netrw may hijack the current buffer#".bufnr("%")."<".curbuf.">",'~'.expand("")) +" call Decho("deciding if netrw may highjack the current buffer#".bufnr("%")."<".curbuf.">",'~'.expand("")) " call Decho("..dirname<".dirname."> IF dirname == bufname",'~'.expand("")) " call Decho("..curbuf<".curbuf.">",'~'.expand("")) " call Decho("..line($)=".line("$")." AND this is 1",'~'.expand("")) @@ -4244,7 +4257,7 @@ fun! s:NetrwGetBuffer(islocal,dirname) " call Dret("s:NetrwGetBuffer 0 : highjacking buffer#".bufnr("%")) return 0 else " DEBUG -" call Decho("..did NOT hijack buffer",'~'.expand("")) +" call Decho("..did NOT highjack buffer",'~'.expand("")) endif " Aug 14, 2021: was thinking about looking for a [No Name] buffer here and using it, but that might cause problems @@ -4280,19 +4293,25 @@ fun! s:NetrwGetBuffer(islocal,dirname) else " Re-use the buffer " call Decho("--re-use buffer#".bufnum." (bufnum#".bufnum.">=0 AND bufexists(".bufnum.")=".bufexists(bufnum)."!=0)",'~'.expand("")) + " ignore all events let eikeep= &ei setl ei=all - if getline(2) =~# '^" Netrw Directory Listing' -" call Decho(" getline(2)<".getline(2).'> matches "Netrw Directory Listing" : using keepalt b '.bufnum,'~'.expand("")) - exe "sil! NetrwKeepj noswapfile keepalt b ".bufnum + + if &ft == "netrw" +" call Decho("buffer type is netrw; not using keepalt with b ".bufnum) + exe "sil! NetrwKeepj noswapfile b ".bufnum +" call Dredir("ls!","one") else -" call Decho(" getline(2)<".getline(2).'> does not match "Netrw Directory Listing" : using b '.bufnum,'~'.expand("")) - exe "sil! NetrwKeepj noswapfile keepalt b ".bufnum +" call Decho("buffer type is not netrw; using keepalt with b ".bufnum) + call s:NetrwEditBuf(bufnum) +" call Dredir("ls!","two") endif " call Decho(" line($)=".line("$"),'~'.expand("")) if bufname("%") == '.' call s:NetrwBufRename(getcwd()) endif + + " restore ei let &ei= eikeep if line("$") <= 1 && getline(1) == "" @@ -4943,7 +4962,7 @@ fun! s:NetrwBrowseChgDir(islocal,newdir,...) " the point where netrw actually edits the (local) file " if its local only: LocalBrowseCheck() doesn't edit a file, but NetrwBrowse() will - " no keepalt to support :e # to return to a directory listing + " use keepalt to support :e # to return to a directory listing if !&mod " if e the new file would fail due to &mod, then don't change any of the flags let dolockout= 1 @@ -4954,12 +4973,8 @@ fun! s:NetrwBrowseChgDir(islocal,newdir,...) " others like c-^ to return to the netrw buffer " Apr 30, 2020: used to have e! here. That can cause loss of a modified file, " so emit error E37 instead. - if exists("g:netrw_altfile") && g:netrw_altfile - exe "NetrwKeepj keepalt e ".fnameescape(dirname) - else - exe "NetrwKeepj e ".fnameescape(dirname) - endif -" call Decho("edit-a-file: after e! ".dirname.": hidden=".&hidden." bufhidden<".&bufhidden."> mod=".&mod,'~'.expand("")) + call s:NetrwEditFile("e","",dirname) +" call Decho("edit-a-file: after e ".dirname.": hidden=".&hidden." bufhidden<".&bufhidden."> mod=".&mod,'~'.expand("")) " COMBAK -- cuc cul related call s:NetrwCursor(1) if &hidden || &bufhidden == "hide" @@ -5300,8 +5315,8 @@ fun! netrw#BrowseX(fname,remote) " g:Netrw_corehandler is a List of function references (see :help Funcref) " call Decho("g:Netrw_corehandler is a List",'~'.expand("")) for Fncref in g:Netrw_corehandler - if type(FncRef) == 2 - call FncRef(a:fname) + if type(Fncref) == 2 + call Fncref(a:fname) endif endfor endif @@ -5374,6 +5389,8 @@ fun! netrw#BrowseX(fname,remote) else let redir= &srr . "/dev/null" endif + else + let redir= "" endif " call Decho("set up redirection: redir{".redir."} srr{".&srr."}",'~'.expand("")) @@ -5668,6 +5685,35 @@ fun! s:NetrwClearExplore() " call Dret("s:NetrwClearExplore") endfun +" --------------------------------------------------------------------- +" s:NetrwEditBuf: decides whether or not to use keepalt to edit a buffer {{{2 +fun! s:NetrwEditBuf(bufnum) +" call Dfunc("s:NetrwEditBuf(fname<".a:bufnum.">)") + if exists("g:netrw_altfile") && g:netrw_altfile && &ft == "netrw" +" call Decho("exe sil! NetrwKeepj keepalt noswapfile b ".fnameescape(a:bufnum)) + exe "sil! NetrwKeepj keepalt noswapfile b ".fnameescape(a:bufnum) + else +" call Decho("exe sil! NetrwKeepj noswapfile b ".fnameescape(a:bufnum)) + exe "sil! NetrwKeepj noswapfile b ".fnameescape(a:bufnume) + endif +" call Dret("s:NetrwEditBuf") +endfun + +" --------------------------------------------------------------------- +" s:NetrwEditFile: decides whether or not to use keepalt to edit a file {{{2 +" NetrwKeepj [keepalt] +fun! s:NetrwEditFile(cmd,opt,fname) +" call Dfunc("s:NetrwEditFile(cmd<".a:cmd.">,opt<".a:opt.">,fname<".a:fname.">) ft<".&ft.">") + if exists("g:netrw_altfile") && g:netrw_altfile && &ft == "netrw" +" call Decho("exe NetrwKeepj keepalt ".a:opt." ".a:cmd." ".fnameescape(a:fname)) + exe "NetrwKeepj keepalt ".a:opt." ".a:cmd." ".fnameescape(a:fname) + else +" call Decho("exe NetrwKeepj ".a:opt." ".a:cmd." ".fnameescape(a:fname)) + exe "NetrwKeepj ".a:opt." ".a:cmd." ".fnameescape(a:fname) + endif +" call Dret("s:NetrwEditFile") +endfun + " --------------------------------------------------------------------- " s:NetrwExploreListUniq: {{{2 fun! s:NetrwExploreListUniq(explist) @@ -7756,8 +7802,16 @@ fun! s:NetrwMarkFileMove(islocal) " call Decho("movecmd<".movecmd."> (#3 linux or cygwin)",'~'.expand("")) endif for fname in s:netrwmarkfilelist_{bufnr("%")} + if g:netrw_keepdir + " Jul 19, 2022: fixing file move when g:netrw_keepdir is 1 + let fname= b:netrw_curdir."/".fname + endif if !g:netrw_cygwin && (has("win32") || has("win95") || has("win64") || has("win16")) let fname= substitute(fname,'/','\\','g') + if g:netrw_keepdir + " Jul 19, 2022: fixing file move when g:netrw_keepdir is 1 + let fname= b:netrw_curdir."\\".fname + endif endif " call Decho("system(".movecmd." ".s:ShellEscape(fname)." ".tgt.")",'~'.expand("")) let ret= system(movecmd.g:netrw_localmovecmdopt." ".s:ShellEscape(fname)." ".tgt) @@ -8475,21 +8529,28 @@ endfun " choice = 2 : didn't save modified file, opened window " choice = 3 : cancel open fun! s:NetrwPrevWinOpen(islocal) -" call Dfunc("s:NetrwPrevWinOpen(islocal=".a:islocal.")") +" call Dfunc("s:NetrwPrevWinOpen(islocal=".a:islocal.") win#".winnr()) let ykeep= @@ " grab a copy of the b:netrw_curdir to pass it along to newly split windows let curdir = b:netrw_curdir +" call Decho("COMBAK#1: mod=".&mod." win#".winnr()) " get last window number and the word currently under the cursor let origwin = winnr() let lastwinnr = winnr("$") - let curword = s:NetrwGetWord() - let choice = 0 - let s:prevwinopen= 1 " lets s:NetrwTreeDir() know that NetrwPrevWinOpen called it +" call Decho("origwin#".origwin." lastwinnr#".lastwinnr) +" call Decho("COMBAK#2: mod=".&mod." win#".winnr()) + let curword = s:NetrwGetWord() + let choice = 0 + let s:prevwinopen= 1 " lets s:NetrwTreeDir() know that NetrwPrevWinOpen called it (s:NetrwTreeDir() will unlet s:prevwinopen) +" call Decho("COMBAK#3: mod=".&mod." win#".winnr()) let s:treedir = s:NetrwTreeDir(a:islocal) +" call Decho("COMBAK#4: mod=".&mod." win#".winnr()) let curdir = s:treedir +" call Decho("COMBAK#5: mod=".&mod." win#".winnr()) " call Decho("winnr($)#".lastwinnr." curword<".curword.">",'~'.expand("")) +" call Decho("COMBAK#6: mod=".&mod." win#".winnr()) let didsplit = 0 if lastwinnr == 1 @@ -8512,11 +8573,26 @@ fun! s:NetrwPrevWinOpen(islocal) " call Decho("did split",'~'.expand("")) else +" call Decho("COMBAK#7: mod=".&mod." win#".winnr()) NetrwKeepj call s:SaveBufVars() +" call Decho("COMBAK#8: mod=".&mod." win#".winnr()) let eikeep= &ei +" call Decho("COMBAK#9: mod=".&mod." win#".winnr()) setl ei=all +" call Decho("COMBAK#10: mod=".&mod." win#".winnr()) wincmd p +" call Decho("COMBAK#11: mod=".&mod) " call Decho("wincmd p (now in win#".winnr().") curdir<".curdir.">",'~'.expand("")) +" call Decho("COMBAK#12: mod=".&mod) + + if exists("s:lexplore_win") && s:lexplore_win == winnr() + " whoops -- user trying to open file in the Lexplore window. + " Use Lexplore's opening-file window instead. +" call Decho("whoops -- user trying to open file in Lexplore Window. Use win#".g:netrw_chgwin." instead") +" exe g:netrw_chgwin."wincmd w" + wincmd p + call s:NetrwBrowse(0,s:NetrwBrowseChgDir(0,s:NetrwGetWord())) + endif " prevwinnr: the window number of the "prev" window " prevbufnr: the buffer number of the buffer in the "prev" window @@ -8526,8 +8602,10 @@ fun! s:NetrwPrevWinOpen(islocal) let prevbufname = bufname("%") let prevmod = &mod let bnrcnt = 0 +" call Decho("COMBAK#13: mod=".&mod." win#".winnr()) NetrwKeepj call s:RestoreBufVars() " call Decho("after wincmd p: win#".winnr()." win($)#".winnr("$")." origwin#".origwin." &mod=".&mod." bufname(%)<".bufname("%")."> prevbufnr=".prevbufnr,'~'.expand("")) +" call Decho("COMBAK#14: mod=".&mod." win#".winnr()) " if the previous window's buffer has been changed (ie. its modified flag is set), " and it doesn't appear in any other extant window, then ask the @@ -8537,6 +8615,7 @@ fun! s:NetrwPrevWinOpen(islocal) windo if winbufnr(0) == prevbufnr | let bnrcnt=bnrcnt+1 | endif " call Decho("prevbufnr=".prevbufnr." bnrcnt=".bnrcnt." buftype=".&bt." winnr()=".winnr()." prevwinnr#".prevwinnr,'~'.expand("")) exe prevwinnr."wincmd w" +" call Decho("COMBAK#15: mod=".&mod." win#".winnr()) if bnrcnt == 1 && &hidden == 0 " only one copy of the modified buffer in a window, and @@ -8544,6 +8623,7 @@ fun! s:NetrwPrevWinOpen(islocal) let choice = confirm("Save modified buffer<".prevbufname."> first?","&Yes\n&No\n&Cancel") " call Decho("prevbufname<".prevbufname."> choice=".choice." current-winnr#".winnr(),'~'.expand("")) let &ei= eikeep +" call Decho("COMBAK#16: mod=".&mod." win#".winnr()) if choice == 1 " Yes -- write file & then browse @@ -8576,6 +8656,7 @@ fun! s:NetrwPrevWinOpen(islocal) endif let &ei= eikeep endif +" call Decho("COMBAK#17: mod=".&mod." win#".winnr()) " restore b:netrw_curdir (window split/enew may have lost it) let b:netrw_curdir= curdir @@ -9263,19 +9344,23 @@ fun! s:NetrwTreeDir(islocal) if exists("s:prevwinopen") unlet s:prevwinopen endif +" call Decho("COMBAK#18 : mod=".&mod." win#".winnr()) if !exists("b:netrw_curdir") || b:netrw_curdir == "" let b:netrw_curdir= getcwd() endif let treedir = b:netrw_curdir " call Decho("set initial treedir<".treedir.">",'~'.expand("")) +" call Decho("COMBAK#19 : mod=".&mod." win#".winnr()) let s:treecurpos= winsaveview() " call Decho("saving posn to s:treecurpos<".string(s:treecurpos).">",'~'.expand("")) +" call Decho("COMBAK#20 : mod=".&mod." win#".winnr()) if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST " call Decho("w:netrw_liststyle is TREELIST:",'~'.expand("")) " call Decho("line#".line(".")." getline(.)<".getline('.')."> treecurpos<".string(s:treecurpos).">",'~'.expand("")) +" call Decho("COMBAK#21 : mod=".&mod." win#".winnr()) " extract tree directory if on a line specifying a subdirectory (ie. ends with "/") let curline= substitute(getline('.'),"\t -->.*$",'','') @@ -9291,6 +9376,7 @@ fun! s:NetrwTreeDir(islocal) " call Decho("do not extract tree subdirectory from current line and set treedir to empty",'~'.expand("")) let treedir= "" endif +" call Decho("COMBAK#22 : mod=".&mod." win#".winnr()) " detect user attempting to close treeroot " call Decho("check if user is attempting to close treeroot",'~'.expand("")) @@ -9306,10 +9392,12 @@ fun! s:NetrwTreeDir(islocal) " else " Decho " call Decho(".user not attempting to close treeroot",'~'.expand("")) endif +" call Decho("COMBAK#23 : mod=".&mod." win#".winnr()) " call Decho("islocal=".a:islocal." curline<".curline.">",'~'.expand("")) let potentialdir= s:NetrwFile(substitute(curline,'^'.s:treedepthstring.'\+ \(.*\)@$','\1','')) " call Decho("potentialdir<".potentialdir."> isdir=".isdirectory(potentialdir),'~'.expand("")) +" call Decho("COMBAK#24 : mod=".&mod." win#".winnr()) " COMBAK: a symbolic link may point anywhere -- so it will be used to start a new treetop " if a:islocal && curline =~ '@$' && isdirectory(s:NetrwFile(potentialdir)) @@ -9323,10 +9411,12 @@ fun! s:NetrwTreeDir(islocal) let treedir = s:NetrwTreePath(w:netrw_treetop) " endif endif +" call Decho("COMBAK#25 : mod=".&mod." win#".winnr()) " sanity maintenance: keep those //s away... let treedir= substitute(treedir,'//$','/','') " call Decho("treedir<".treedir.">",'~'.expand("")) +" call Decho("COMBAK#26 : mod=".&mod." win#".winnr()) " call Dret("s:NetrwTreeDir <".treedir."> : (side effect) s:treecurpos<".(exists("s:treecurpos")? string(s:treecurpos) : 'n/a').">") return treedir @@ -10687,7 +10777,8 @@ fun! netrw#LocalBrowseCheck(dirname) " call Dfunc("netrw#LocalBrowseCheck(dirname<".a:dirname.">)") " call Decho("isdir<".a:dirname."> =".isdirectory(s:NetrwFile(a:dirname)).((exists("s:treeforceredraw")? " treeforceredraw" : "")).'~'.expand("")) " call Decho("settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo,'~'.expand("")) -" call Dredir("ls!","netrw#LocalBrowseCheck") + " getting E930: Cannot use :redir inside execute +"" call Dredir("ls!","netrw#LocalBrowseCheck") " call Decho("tab#".tabpagenr()." win#".winnr()." buf#".bufnr("%")."<".bufname("%")."> line#".line(".")." col#".col(".")." winline#".winline()." wincol#".wincol(),'~'.expand("")) " call Decho("current buffer#".bufnr("%")."<".bufname("%")."> ft=".&ft,'~'.expand("")) @@ -10981,12 +11072,15 @@ fun! s:LocalListing() if w:netrw_liststyle == s:LONGLIST let sz = getfsize(filename) - let fsz = strpart(" ",1,15-strlen(sz)).sz + let szlen = 15 - (strdisplaywidth(longfile) - g:netrw_maxfilenamelen) + let szlen = (szlen > 0) ? szlen : 0 + let fsz = printf("%".szlen."S",sz) + if g:netrw_sizestyle =~# "[hH]" let sz= s:NetrwHumanReadable(sz) endif - let longfile= printf("%-".(g:netrw_maxfilenamelen+1)."s",pfile) - let pfile = longfile.sz." ".strftime(g:netrw_timefmt,getftime(filename)) + let longfile= printf("%-".g:netrw_maxfilenamelen."S",pfile) + let pfile = longfile." ".sz." ".strftime(g:netrw_timefmt,getftime(filename)) " call Decho("longlist support: sz=".sz." fsz=".fsz,'~'.expand("")) endif @@ -11285,34 +11379,8 @@ fun! s:NetrwLocalRmFile(path,fname,all) let rmfile= substitute(rmfile,'[\/]$','','e') if all || ok =~# 'y\%[es]' || ok == "" - if v:version < 704 || (v:version == 704 && !has("patch1107")) -" " call Decho("1st attempt: system(netrw#WinPath(".g:netrw_localrmdir.') '.s:ShellEscape(rmfile).')','~'.expand("")) - call system(netrw#WinPath(g:netrw_localrmdir).' '.s:ShellEscape(rmfile)) -" " call Decho("v:shell_error=".v:shell_error,'~'.expand("")) - - if v:shell_error != 0 -" " call Decho("2nd attempt to remove directory<".rmfile.">",'~'.expand("")) - let errcode= s:NetrwDelete(rmfile) -" " call Decho("errcode=".errcode,'~'.expand("")) - - if errcode != 0 - if has("unix") -" " call Decho("3rd attempt to remove directory<".rmfile.">",'~'.expand("")) - call system("rm ".s:ShellEscape(rmfile)) - if v:shell_error != 0 && !exists("g:netrw_quiet") - call netrw#ErrorMsg(s:ERROR,"unable to remove directory<".rmfile."> -- is it empty?",34) - let ok="no" - endif - elseif !exists("g:netrw_quiet") - call netrw#ErrorMsg(s:ERROR,"unable to remove directory<".rmfile."> -- is it empty?",35) - let ok="no" - endif - endif - endif - else - if delete(rmfile,"d") - call netrw#ErrorMsg(s:ERROR,"unable to delete directory <".rmfile.">!",103) - endif + if delete(rmfile,"d") + call netrw#ErrorMsg(s:ERROR,"unable to delete directory <".rmfile.">!",103) endif endif endif @@ -11907,13 +11975,13 @@ fun! s:NetrwEnew(...) if exists("b:netrw_prvdir") |let netrw_prvdir = b:netrw_prvdir |endif NetrwKeepj call s:NetrwOptionsRestore("w:") -" call Decho("generate a buffer with NetrwKeepj keepalt enew!",'~'.expand("")) +" call Decho("generate a buffer with NetrwKeepj enew!",'~'.expand("")) " when tree listing uses file TreeListing... a new buffer is made. " Want the old buffer to be unlisted. " COMBAK: this causes a problem, see P43 " setl nobl let netrw_keepdiff= &l:diff - noswapfile NetrwKeepj keepalt enew! + call s:NetrwEditFile("enew!","","") let &l:diff= netrw_keepdiff " call Decho("bufnr($)=".bufnr("$")."<".bufname(bufnr("$"))."> winnr($)=".winnr("$"),'~'.expand("")) NetrwKeepj call s:NetrwOptionsSave("w:") @@ -11962,7 +12030,7 @@ endfun " s:NetrwExe: executes a string using "!" {{{2 fun! s:NetrwExe(cmd) " call Dfunc("s:NetrwExe(a:cmd<".a:cmd.">)") - if has("win32") && &shell !~? 'cmd' && !g:netrw_cygwin + if has("win32") && &shell !~? 'cmd\|pwsh\|powershell' && !g:netrw_cygwin " call Decho("using win32:",expand("")) let savedShell=[&shell,&shellcmdflag,&shellxquote,&shellxescape,&shellquote,&shellpipe,&shellredir,&shellslash] set shell& shellcmdflag& shellxquote& shellxescape& @@ -12631,3 +12699,54 @@ unlet s:keepcpo " Modelines: {{{1 " =============== " vim:ts=8 fdm=marker +" doing autoload/netrw.vim version v172g ~57 +" varname value=0 ~1 +" varname value=0 ~1 +" varname value=1 ~1 +" varname value=2 ~1 +" varname value=3 ~1 +" varname value=4 ~1 +" varname value=2 ~1 +" varname value=-q -O ~1 +" varname value=curl -T ~1 +" varname value=keepj ~1 +" varname value=rcp ~1 +" varname value=rsync ~1 +" varname value=/ ~1 +" varname value=scp -q ~1 +" varname value=sftp ~1 +" varname value=ssh ~1 +" varname value=0 ~1 +" varname value=1 ~1 +" varname value=1 ~1 +" varname value=0 ~1 +" varname value=noma nomod nonu nobl nowrap ro nornu ~1 +" varname value=-1 ~1 +" varname value=1 ~1 +" varname value=gzip ~1 +" varname value=ctags ~1 +" varname value=2 ~1 +" (netrw) COMBAK: cuc=0 cul=0 initialization of s:netrw_cu[cl] +" varname value=/cygdrive ~1 +" varname value=0 ~1 +" varname value=0 ~1 +" varname value={ ".gz" : "gunzip", ".bz2" : "bunzip2", ".zip" : "unzip", ".tar" : "tar -xf", ".xz" : "unxz" } ~1 +" varname value=10 ~1 +" varname value=0 ~1 +" varname value=1 ~1 +" varname value=^total\s\+\d\+$\|^Trying\s\+\d\+.*$\|^KERBEROS_V\d rejected\|^Security extensions not\|No such file\|: connect to address [0-9a-fA-F:]*: No route to host$ ~1 +" varname value=binary ~1 +" varname value=1 ~1 +" varname value=1 ~1 +" varname value= ~1 +" varname value=mkdir ~1 +" varname value=mkdir ~1 +" varname value=0 ~1 +" varname value=*./[\~ ~1 +" varname value=32 ~1 +" varname value=1 ~1 +" varname value=ssh USEPORT HOSTNAME mkdir ~1 +" varname value=1 ~1 +" varname value=0 ~1 +" varname value=chmod PERM FILENAME ~1 +" varname value=0 ~1 -- cgit From c11986ed1a816d7ebcb5a5f707e3ef884f278293 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Mon, 15 May 2023 09:38:32 +0200 Subject: vim-patch:b7398fe41c9e (#23627) Update runtime files https://github.com/vim/vim/commit/b7398fe41c9e1e731d058105a34158871ee83e3f Co-authored-by: Bram Moolenaar --- runtime/autoload/netrw.vim | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'runtime/autoload/netrw.vim') diff --git a/runtime/autoload/netrw.vim b/runtime/autoload/netrw.vim index 6c9938d8bb..c9f66f7927 100644 --- a/runtime/autoload/netrw.vim +++ b/runtime/autoload/netrw.vim @@ -1,7 +1,7 @@ " netrw.vim: Handles file transfer and remote directory listing across " AUTOLOAD SECTION -" Date: Mar 15, 2023 -" Version: 172 +" Date: May 03, 2023 +" Version: 173 " Maintainer: Charles E Campbell " GetLatestVimScripts: 1075 1 :AutoInstall: netrw.vim " Copyright: Copyright (C) 2016 Charles E. Campbell {{{1 @@ -43,7 +43,7 @@ if exists("s:needspatches") endfor endif -let g:loaded_netrw = "v172" +let g:loaded_netrw = "v173" if !exists("s:NOTE") let s:NOTE = 0 let s:WARNING = 1 @@ -5694,7 +5694,7 @@ fun! s:NetrwEditBuf(bufnum) exe "sil! NetrwKeepj keepalt noswapfile b ".fnameescape(a:bufnum) else " call Decho("exe sil! NetrwKeepj noswapfile b ".fnameescape(a:bufnum)) - exe "sil! NetrwKeepj noswapfile b ".fnameescape(a:bufnume) + exe "sil! NetrwKeepj noswapfile b ".fnameescape(a:bufnum) endif " call Dret("s:NetrwEditBuf") endfun -- cgit From 8758c6fb875ff5446c0dff2166e9c3392c2c31d6 Mon Sep 17 00:00:00 2001 From: Frede Date: Thu, 29 Jun 2023 23:14:14 +0200 Subject: feat(defaults): set g:netrw_use_errorwindow = 0 #24179 Problem: netrw uses a bespoke window to show messages. Solution: change the default so that netrw uses normal vim :echoerr --- runtime/autoload/netrw.vim | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'runtime/autoload/netrw.vim') diff --git a/runtime/autoload/netrw.vim b/runtime/autoload/netrw.vim index c9f66f7927..be170d8aec 100644 --- a/runtime/autoload/netrw.vim +++ b/runtime/autoload/netrw.vim @@ -211,10 +211,8 @@ let g:netrw_localmovecmdopt = "" " --------------------------------------------------------------------- " Default values for netrw's global protocol variables {{{2 -if (v:version > 802 || (v:version == 802 && has("patch486"))) && has("balloon_eval") && !exists("s:initbeval") && !exists("g:netrw_nobeval") && has("syntax") && exists("g:syntax_on") && has("mouse") - call s:NetrwInit("g:netrw_use_errorwindow",2) -else - call s:NetrwInit("g:netrw_use_errorwindow",1) +if !exists("g:netrw_use_errorwindow") + let g:netrw_use_errorwindow = 0 endif if !exists("g:netrw_dav_cmd") -- cgit From 9de5cb0b32f60bb0060335b1e0f4e4dd1c6cbf73 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Sun, 17 Sep 2023 19:20:16 +0200 Subject: vim-patch:d8b86c937a41 runtime(netrw): fix filetype detection for remote editing files closes: vim/vim#12990 closes: vim/vim#12992 this partially reverses commit 71badf9 by commenting out the line that intentionally sets the filetype to an empty string. https://github.com/vim/vim/commit/d8b86c937a419db69239a8bb879f0050be0f8e1d Co-authored-by: Christian Brabandt --- runtime/autoload/netrw.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'runtime/autoload/netrw.vim') diff --git a/runtime/autoload/netrw.vim b/runtime/autoload/netrw.vim index be170d8aec..2dd5cf45bf 100644 --- a/runtime/autoload/netrw.vim +++ b/runtime/autoload/netrw.vim @@ -2951,7 +2951,7 @@ fun! s:NetrwGetFile(readcmd, tfile, method) " to process this detection correctly. " call Decho("detect filetype of local version of remote file<".rfile.">",'~'.expand("")) " call Decho("..did_filetype()=".did_filetype()) - setl ft= +" setl ft= " call Decho("..initial filetype<".&ft."> for buf#".bufnr()."<".bufname().">") let iskkeep= &isk setl isk-=/ -- cgit From 0ff13a6a5a0a4d534f4ce9619fa4ccb02f126d53 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Thu, 5 Oct 2023 08:39:23 +0200 Subject: vim-patch:4dbb2669e9ed runtime(netrw): error when trying to :bd unloaded buffer closes: vim/vim#13215 closes: vim/vim#13082 https://github.com/vim/vim/commit/4dbb2669e9ed9ec6864705dcb569715e417e1303 Co-authored-by: yasuda --- runtime/autoload/netrw.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'runtime/autoload/netrw.vim') diff --git a/runtime/autoload/netrw.vim b/runtime/autoload/netrw.vim index 2dd5cf45bf..2ed3e9ca39 100644 --- a/runtime/autoload/netrw.vim +++ b/runtime/autoload/netrw.vim @@ -11934,9 +11934,9 @@ fun! s:NetrwBufRemover(bufid) " call Decho("buf#".a:bufid." has name <".bufname(a:bufid).">","~".expand("")) " call Decho("buf#".a:bufid." has winid#".bufwinid(a:bufid),"~".expand("")) - if a:bufid > 1 && !buflisted(a:bufid) && bufname(a:bufid) == "" && bufwinid(a:bufid) == -1 + if a:bufid > 1 && !buflisted(a:bufid) && bufloaded(a:bufid) && bufname(a:bufid) == "" && bufwinid(a:bufid) == -1 " call Decho("(s:NetrwBufRemover) removing buffer#".a:bufid,"~".expand("")) - exe "bd! ".a:bufid + exe "sil! bd! ".a:bufid endif " call Dret("s:NetrwBufRemover") -- cgit From ac6d8d008720f80bdbc5f44c6a75aa78c816dc52 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Fri, 6 Oct 2023 09:50:53 +0200 Subject: vim-patch:f449825ae238 runtime(netrw): Update `.netrwbook` immediately on bookmark change (vim/vim#13276) closes: vim/vim#9738 https://github.com/vim/vim/commit/f449825ae23865437a74ea4140fd32780c02ce43 Co-authored-by: KSR-Yasuda <31273423+KSR-Yasuda@users.noreply.github.com> --- runtime/autoload/netrw.vim | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'runtime/autoload/netrw.vim') diff --git a/runtime/autoload/netrw.vim b/runtime/autoload/netrw.vim index 2ed3e9ca39..22431d89e1 100644 --- a/runtime/autoload/netrw.vim +++ b/runtime/autoload/netrw.vim @@ -3469,6 +3469,11 @@ fun! s:NetrwBookHistHandler(chg,curdir) echo "bookmarked the current directory" endif + try + call s:NetrwBookHistSave() + catch + endtry + elseif a:chg == 1 " change to the bookmarked directory " call Decho("(user: <".v:count."gb>) change to the bookmarked directory",'~'.expand("")) @@ -3613,6 +3618,11 @@ fun! s:NetrwBookHistHandler(chg,curdir) " call Decho("g:netrw_bookmarklist=".string(g:netrw_bookmarklist),'~'.expand("")) endif " call Decho("resulting g:netrw_bookmarklist=".string(g:netrw_bookmarklist),'~'.expand("")) + + try + call s:NetrwBookHistSave() + catch + endtry endif call s:NetrwBookmarkMenu() call s:NetrwTgtMenu() -- cgit From a6cccd728a5b9363661c3daf79046afe4b37a5ee Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Fri, 6 Oct 2023 09:51:19 +0200 Subject: vim-patch:0e958410046a runtime(netrw): diff (`df`) may open the wrong window (vim/vim#13275) closes: vim/vim#11359 https://github.com/vim/vim/commit/0e958410046aa764ec73b14b1d2839053b31d242 Co-authored-by: KSR-Yasuda <31273423+KSR-Yasuda@users.noreply.github.com> --- runtime/autoload/netrw.vim | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'runtime/autoload/netrw.vim') diff --git a/runtime/autoload/netrw.vim b/runtime/autoload/netrw.vim index 22431d89e1..dcaa075608 100644 --- a/runtime/autoload/netrw.vim +++ b/runtime/autoload/netrw.vim @@ -7332,8 +7332,7 @@ fun! s:NetrwMarkFileDiff(islocal) exe "NetrwKeepj e ".fnameescape(fname) diffthis elseif cnt == 2 || cnt == 3 - vsplit - wincmd l + below vsplit " call Decho("diffthis: ".fname,'~'.expand("")) exe "NetrwKeepj e ".fnameescape(fname) diffthis -- cgit From 3222f0ad0079ce4bd4e45886a00e4fe4685fb5dd Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 16 Oct 2023 16:36:25 +0800 Subject: vim-patch:dbf749bd5aae (#25665) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit runtime: Fix more typos (vim/vim#13354) * Fix more typos * Fix typos in ignored runtime/ directory https://github.com/vim/vim/commit/dbf749bd5aaef6ea2d28bce081349785d174d96a Co-authored-by: Viktor Szépe --- runtime/autoload/netrw.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'runtime/autoload/netrw.vim') diff --git a/runtime/autoload/netrw.vim b/runtime/autoload/netrw.vim index dcaa075608..8b29ea9dfa 100644 --- a/runtime/autoload/netrw.vim +++ b/runtime/autoload/netrw.vim @@ -1914,7 +1914,7 @@ endfun " Doing this means that netrw will not come up as having changed a " setting last when it really didn't actually change it. " -" Used by s:NetrwOptionsRestore() to restore each netrw-senstive setting +" Used by s:NetrwOptionsRestore() to restore each netrw-sensitive setting " keepvars are set up by s:NetrwOptionsSave fun! s:NetrwRestoreSetting(keepvar,setting) """ call Dfunc("s:NetrwRestoreSetting(a:keepvar<".a:keepvar."> a:setting<".a:setting.">)") @@ -5515,7 +5515,7 @@ fun! netrw#BrowseX(fname,remote) " cleanup: remove temporary file, " delete current buffer if success with handler, " return to prior buffer (directory listing) - " Feb 12, 2008: had to de-activiate removal of + " Feb 12, 2008: had to de-activate removal of " temporary file because it wasn't getting seen. " if remote == 1 && fname != a:fname "" call Decho("deleting temporary file<".fname.">",'~'.expand("")) -- cgit From 9455f6b17c6d1009af5d37d62884fe3042abdfa0 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Fri, 27 Oct 2023 19:20:07 +0200 Subject: vim-patch:650dcfc8d12e runtime(netrw): don't echo empty lines (vim/vim#13431) https://github.com/vim/vim/commit/650dcfc8d12e68aa05a358301ec15f9e6dbd03ba Co-authored-by: nwounkn --- runtime/autoload/netrw.vim | 3 --- 1 file changed, 3 deletions(-) (limited to 'runtime/autoload/netrw.vim') diff --git a/runtime/autoload/netrw.vim b/runtime/autoload/netrw.vim index 8b29ea9dfa..e3e28b6de2 100644 --- a/runtime/autoload/netrw.vim +++ b/runtime/autoload/netrw.vim @@ -1134,7 +1134,6 @@ fun! netrw#Explore(indx,dosplit,style,...) 2match none if exists("s:explore_match") | unlet s:explore_match | endif if exists("s:explore_prvdir") | unlet s:explore_prvdir | endif - echo " " " call Decho("cleared explore match list",'~'.expand("")) endif @@ -5688,8 +5687,6 @@ fun! s:NetrwClearExplore() if exists("w:netrw_explore_list") |unlet w:netrw_explore_list |endif if exists("w:netrw_explore_bufnr") |unlet w:netrw_explore_bufnr |endif " redraw! - echo " " - echo " " " call Dret("s:NetrwClearExplore") endfun -- cgit From 059dc3f4a6b94cd028c5041d682982e6eed9bc87 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 22 Nov 2023 11:06:46 +0800 Subject: vim-patch:cb0c113ddc01 (#26147) runtime(netrw): expand $COMSPEC without applying 'wildignore' (vim/vim#13542) When expanding $COMSPEC and a user has set :set wildignore=*.exe netrw won't be able to properly cmd.exe, because it does not ignore the wildignore setting. So let's explicitly use expand() without applying the 'wildignore' and 'suffixes' settings to the result closes: vim/vim#13426 https://github.com/vim/vim/commit/cb0c113ddc0101b05a27c040774cb7106fc74cd4 Co-authored-by: Christian Brabandt --- runtime/autoload/netrw.vim | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'runtime/autoload/netrw.vim') diff --git a/runtime/autoload/netrw.vim b/runtime/autoload/netrw.vim index e3e28b6de2..9dc9d28b1a 100644 --- a/runtime/autoload/netrw.vim +++ b/runtime/autoload/netrw.vim @@ -1,7 +1,9 @@ " netrw.vim: Handles file transfer and remote directory listing across " AUTOLOAD SECTION " Date: May 03, 2023 -" Version: 173 +" Version: 173a +" Last Change: +" 2023 Nov 21 by Vim Project: ignore wildignore when expanding $COMSPEC (v173a) " Maintainer: Charles E Campbell " GetLatestVimScripts: 1075 1 :AutoInstall: netrw.vim " Copyright: Copyright (C) 2016 Charles E. Campbell {{{1 @@ -398,7 +400,7 @@ if !exists("g:netrw_localcopycmd") if g:netrw_cygwin let g:netrw_localcopycmd= "cp" else - let g:netrw_localcopycmd = expand("$COMSPEC") + let g:netrw_localcopycmd = expand("$COMSPEC", v:true) let g:netrw_localcopycmdopt= " /c copy" endif elseif has("unix") || has("macunix") @@ -413,7 +415,7 @@ if !exists("g:netrw_localcopydircmd") let g:netrw_localcopydircmd = "cp" let g:netrw_localcopydircmdopt= " -R" else - let g:netrw_localcopydircmd = expand("$COMSPEC") + let g:netrw_localcopydircmd = expand("$COMSPEC", v:true) let g:netrw_localcopydircmdopt= " /c xcopy /e /c /h /i /k" endif elseif has("unix") @@ -434,7 +436,7 @@ if has("win32") || has("win95") || has("win64") || has("win16") if g:netrw_cygwin call s:NetrwInit("g:netrw_localmkdir","mkdir") else - let g:netrw_localmkdir = expand("$COMSPEC") + let g:netrw_localmkdir = expand("$COMSPEC", v:true) let g:netrw_localmkdiropt= " /c mkdir" endif else @@ -450,7 +452,7 @@ if !exists("g:netrw_localmovecmd") if g:netrw_cygwin let g:netrw_localmovecmd= "mv" else - let g:netrw_localmovecmd = expand("$COMSPEC") + let g:netrw_localmovecmd = expand("$COMSPEC", v:true) let g:netrw_localmovecmdopt= " /c move" endif elseif has("unix") || has("macunix") -- cgit From 62dc1f26632fd0c915e7521a4e13a823142ec44d Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 23 Nov 2023 17:02:53 +0800 Subject: vim-patch:8750e3cf81f1 (#26163) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit runtime(netrw): Fix handling of very long filename on longlist style (vim/vim#12150) If there is a file with a very long filename (longer than g:netrw_maxfilenamelen), and if g:netrw_liststyle is set to 1, no space is inserted between the filename and the filesize and the file cannot be opened because of this. E.g.: ``` $ echo hello > 12345678901234567890123456789012 # 32 bytes: OK $ echo hello > 123456789012345678901234567890123 # 33 bytes: not OK $ echo hello > 1234567890123456789012345678901234 # 34 bytes: not OK $ echo hello > こんにちは # multibyte filename $ LC_ALL=C.UTF-8 vim . --clean --cmd "set loadplugins" --cmd "let g:netrw_liststyle=1" ``` Then, it will be shown like this: ``` " ============================================================================ " Netrw Directory Listing (netrw v171) " /cygdrive/c/work/netrw-test " Sorted by name " Sort sequence: [\/]$,\,\.h$,\.c$,\.cpp$,\~\=\*$,*,\.o$,\ " Quick Help: :help -:go up dir D:delete R:rename s:sort-by x:special " ============================================================================== ../ 0 Mon Mar 13 19:25:16 2023 ./ 0 Mon Mar 13 19:44:58 2023 12345678901234567890123456789012 6 Mon Mar 13 19:29:43 2023 12345678901234567890123456789012346 Mon Mar 13 19:32:40 2023 1234567890123456789012345678901236 Mon Mar 13 19:29:49 2023 こんにちは 6 Mon Mar 13 19:30:41 2023 ``` If the length of the filename is 32 bytes, there is a space between the filename and the filesize. However, when it is longer than 32 bytes, no space is shown. Also, you may find that the filesize of the multibyte named file is not aligned. After this patch is applied, the filelist will be shown like this: ``` " ============================================================================ " Netrw Directory Listing (netrw v171) " /cygdrive/c/work/netrw-test " Sorted by name " Sort sequence: [\/]$,\,\.h$,\.c$,\.cpp$,\~\=\*$,*,\.o$,\ " Quick Help: :help -:go up dir D:delete R:rename s:sort-by x:special " ============================================================================== ../ 0 Mon Mar 13 20:49:22 2023 ./ 0 Mon Mar 13 21:12:14 2023 1234567890123456789012345678901 10000 Mon Mar 13 20:57:55 2023 12345678901234567890123456789012 6 Mon Mar 13 19:29:43 2023 123456789012345678901234567890123 6 Mon Mar 13 19:29:49 2023 1234567890123456789012345678901234 6 Mon Mar 13 19:32:40 2023 1234567890123456789012345678901234567 10000 Mon Mar 13 21:03:23 2023 1234567890123456789012345678901234567890 10000 Mon Mar 13 21:03:36 2023 123456789012345678901234567890123456789012 10000 Mon Mar 13 21:03:59 2023 1234567890123456789012345678901234567890123 10000 Mon Mar 13 21:03:45 2023 1234567890123456789012345678901234567890123456 5 Mon Mar 13 21:08:15 2023 12345678901234567890123456789012345678901234567 10 Mon Mar 13 21:05:21 2023 こんにちは 6 Mon Mar 13 19:30:41 2023 ``` Now we have 32 + 2 + 15 = 49 characters for filename and filesize. It tries to align the filesize as much as possible. The last line that has multibyte filename is also aligned. Also fixed the issue that the file list is not shown correctly when g:netrw_sort_by is set to 'size' and g:netrw_sizestyle is set to 'h' or 'H'. https://github.com/vim/vim/commit/8750e3cf81f12132e7b4141501feba586b1ae11d Co-authored-by: K.Takata --- runtime/autoload/netrw.vim | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'runtime/autoload/netrw.vim') diff --git a/runtime/autoload/netrw.vim b/runtime/autoload/netrw.vim index 9dc9d28b1a..b8092ebeeb 100644 --- a/runtime/autoload/netrw.vim +++ b/runtime/autoload/netrw.vim @@ -4,6 +4,7 @@ " Version: 173a " Last Change: " 2023 Nov 21 by Vim Project: ignore wildignore when expanding $COMSPEC (v173a) +" 2023 Nov 22 by Vim Project: fix handling of very long filename on longlist style (v173a) " Maintainer: Charles E Campbell " GetLatestVimScripts: 1075 1 :AutoInstall: netrw.vim " Copyright: Copyright (C) 2016 Charles E. Campbell {{{1 @@ -11077,16 +11078,16 @@ fun! s:LocalListing() " call Decho("pfile <".pfile.">",'~'.expand("")) if w:netrw_liststyle == s:LONGLIST + let longfile= printf("%-".g:netrw_maxfilenamelen."S",pfile) let sz = getfsize(filename) let szlen = 15 - (strdisplaywidth(longfile) - g:netrw_maxfilenamelen) let szlen = (szlen > 0) ? szlen : 0 - let fsz = printf("%".szlen."S",sz) if g:netrw_sizestyle =~# "[hH]" let sz= s:NetrwHumanReadable(sz) endif - let longfile= printf("%-".g:netrw_maxfilenamelen."S",pfile) - let pfile = longfile." ".sz." ".strftime(g:netrw_timefmt,getftime(filename)) + let fsz = printf("%".szlen."S",sz) + let pfile = longfile." ".fsz." ".strftime(g:netrw_timefmt,getftime(filename)) " call Decho("longlist support: sz=".sz." fsz=".fsz,'~'.expand("")) endif @@ -11096,7 +11097,7 @@ fun! s:LocalListing() " call Decho("implementing g:netrw_sort_by=".g:netrw_sort_by." (time)") " call Decho("getftime(".filename.")=".getftime(filename),'~'.expand("")) let t = getftime(filename) - let ft = strpart("000000000000000000",1,18-strlen(t)).t + let ft = printf("%018d",t) " call Decho("exe NetrwKeepj put ='".ft.'/'.pfile."'",'~'.expand("")) let ftpfile= ft.'/'.pfile sil! NetrwKeepj put=ftpfile @@ -11106,10 +11107,7 @@ fun! s:LocalListing() " call Decho("implementing g:netrw_sort_by=".g:netrw_sort_by." (size)") " call Decho("getfsize(".filename.")=".getfsize(filename),'~'.expand("")) let sz = getfsize(filename) - if g:netrw_sizestyle =~# "[hH]" - let sz= s:NetrwHumanReadable(sz) - endif - let fsz = strpart("000000000000000000",1,18-strlen(sz)).sz + let fsz = printf("%018d",sz) " call Decho("exe NetrwKeepj put ='".fsz.'/'.filename."'",'~'.expand("")) let fszpfile= fsz.'/'.pfile sil! NetrwKeepj put =fszpfile -- cgit