Skip to content

Commit aa2ce6f

Browse files
committed
runtime(netrw): fix filetype detection for remote files
fixes: #15961 while at it, remove the Decho comments in the s:NetrwOptionsRestore() function Signed-off-by: Christian Brabandt <cb@256bit.org>
1 parent 05a40e0 commit aa2ce6f

1 file changed

Lines changed: 4 additions & 33 deletions

File tree

runtime/autoload/netrw.vim

Lines changed: 4 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
" 2024 Sep 21 by Vim Project: remove extraneous closing bracket (#15718)
2929
" 2024 Oct 21 by Vim Project: remove netrwFileHandlers (#15895)
3030
" 2024 Oct 27 by Vim Project: clean up gx mapping (#15721)
31+
" 2024 Oct 30 by Vim Project: fix filetype detection for remote files (#15961)
3132
" }}}
3233
" Former Maintainer: Charles E Campbell
3334
" GetLatestVimScripts: 1075 1 :AutoInstall: netrw.vim
@@ -1788,29 +1789,20 @@ endfun
17881789
" ---------------------------------------------------------------------
17891790
" s:NetrwOptionsRestore: restore options (based on prior s:NetrwOptionsSave) {{{2
17901791
fun! s:NetrwOptionsRestore(vt)
1791-
" call Dfunc("s:NetrwOptionsRestore(vt<".a:vt.">) win#".winnr()." buf#".bufnr("%")."<".bufname("%")."> winnr($)=".winnr("$"))
1792-
" call Decho("(s:NetrwOptionsRestore) lines=".&lines)
1793-
" 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("<slnum>"))
17941792
if !exists("{a:vt}netrw_optionsave")
1795-
" call Decho("case ".a:vt."netrw_optionsave : doesn't exist",'~'.expand("<slnum>"))
1796-
1797-
" filereadable() returns zero for remote files (e.g. scp://localhost//etc/fstab)
1798-
if filereadable(expand("%")) || expand("%") =~# '^\w\+://\f\+/'
1799-
" call Decho("..doing filetype detect anyway")
1793+
" filereadable() returns zero for remote files (e.g. scp://user@localhost//etc/fstab)
1794+
" Note: @ may not be in 'isfname', so '^\w\+://\f\+/' may not match
1795+
if filereadable(expand("%")) || expand("%") =~# '^\w\+://\f\+'
18001796
filetype detect
1801-
" 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("<slnum>"))
18021797
else
18031798
setl ft=netrw
18041799
endif
1805-
" call Decho("..ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)",'~'.expand("<slnum>"))
1806-
" call Dret("s:NetrwOptionsRestore : ".a:vt."netrw_optionsave doesn't exist")
18071800
return
18081801
endif
18091802
unlet {a:vt}netrw_optionsave
18101803

18111804
if exists("+acd")
18121805
if exists("{a:vt}netrw_acdkeep")
1813-
" call Decho("g:netrw_keepdir=".g:netrw_keepdir.": getcwd<".getcwd()."> acd=".&acd,'~'.expand("<slnum>"))
18141806
let curdir = getcwd()
18151807
let &l:acd = {a:vt}netrw_acdkeep
18161808
unlet {a:vt}netrw_acdkeep
@@ -1819,53 +1811,43 @@ fun! s:NetrwOptionsRestore(vt)
18191811
endif
18201812
endif
18211813
endif
1822-
" call Decho("(s:NetrwOptionsRestore) #1 lines=".&lines)
18231814
call s:NetrwRestoreSetting(a:vt."netrw_aikeep","&l:ai")
18241815
call s:NetrwRestoreSetting(a:vt."netrw_awkeep","&l:aw")
18251816
call s:NetrwRestoreSetting(a:vt."netrw_blkeep","&l:bl")
18261817
call s:NetrwRestoreSetting(a:vt."netrw_btkeep","&l:bt")
18271818
call s:NetrwRestoreSetting(a:vt."netrw_bombkeep","&l:bomb")
1828-
" call Decho("(s:NetrwOptionsRestore) #2 lines=".&lines)
18291819
call s:NetrwRestoreSetting(a:vt."netrw_cedit","&cedit")
18301820
call s:NetrwRestoreSetting(a:vt."netrw_cikeep","&l:ci")
18311821
call s:NetrwRestoreSetting(a:vt."netrw_cinkeep","&l:cin")
18321822
call s:NetrwRestoreSetting(a:vt."netrw_cinokeep","&l:cino")
18331823
call s:NetrwRestoreSetting(a:vt."netrw_comkeep","&l:com")
1834-
" call Decho("(s:NetrwOptionsRestore) #3 lines=".&lines)
18351824
call s:NetrwRestoreSetting(a:vt."netrw_cpokeep","&l:cpo")
18361825
call s:NetrwRestoreSetting(a:vt."netrw_diffkeep","&l:diff")
18371826
call s:NetrwRestoreSetting(a:vt."netrw_fenkeep","&l:fen")
18381827
if exists("g:netrw_ffkeep") && g:netrw_ffkeep
18391828
call s:NetrwRestoreSetting(a:vt."netrw_ffkeep")","&l:ff")
18401829
endif
1841-
" call Decho("(s:NetrwOptionsRestore) #4 lines=".&lines)
18421830
call s:NetrwRestoreSetting(a:vt."netrw_fokeep" ,"&l:fo")
18431831
call s:NetrwRestoreSetting(a:vt."netrw_gdkeep" ,"&l:gd")
18441832
call s:NetrwRestoreSetting(a:vt."netrw_gokeep" ,"&go")
18451833
call s:NetrwRestoreSetting(a:vt."netrw_hidkeep" ,"&l:hidden")
1846-
" call Decho("(s:NetrwOptionsRestore) #5 lines=".&lines)
18471834
call s:NetrwRestoreSetting(a:vt."netrw_imkeep" ,"&l:im")
18481835
call s:NetrwRestoreSetting(a:vt."netrw_iskkeep" ,"&l:isk")
1849-
" call Decho("(s:NetrwOptionsRestore) #6 lines=".&lines)
18501836
call s:NetrwRestoreSetting(a:vt."netrw_lines" ,"&lines")
1851-
" call Decho("(s:NetrwOptionsRestore) #7 lines=".&lines)
18521837
call s:NetrwRestoreSetting(a:vt."netrw_lskeep" ,"&l:ls")
18531838
call s:NetrwRestoreSetting(a:vt."netrw_makeep" ,"&l:ma")
18541839
call s:NetrwRestoreSetting(a:vt."netrw_magickeep","&l:magic")
18551840
call s:NetrwRestoreSetting(a:vt."netrw_modkeep" ,"&l:mod")
18561841
call s:NetrwRestoreSetting(a:vt."netrw_nukeep" ,"&l:nu")
1857-
" call Decho("(s:NetrwOptionsRestore) #8 lines=".&lines)
18581842
call s:NetrwRestoreSetting(a:vt."netrw_rnukeep" ,"&l:rnu")
18591843
call s:NetrwRestoreSetting(a:vt."netrw_repkeep" ,"&l:report")
18601844
call s:NetrwRestoreSetting(a:vt."netrw_rokeep" ,"&l:ro")
18611845
call s:NetrwRestoreSetting(a:vt."netrw_selkeep" ,"&l:sel")
1862-
" call Decho("(s:NetrwOptionsRestore) #9 lines=".&lines)
18631846
call s:NetrwRestoreSetting(a:vt."netrw_spellkeep","&l:spell")
18641847
call s:NetrwRestoreSetting(a:vt."netrw_twkeep" ,"&l:tw")
18651848
call s:NetrwRestoreSetting(a:vt."netrw_wigkeep" ,"&l:wig")
18661849
call s:NetrwRestoreSetting(a:vt."netrw_wrapkeep" ,"&l:wrap")
18671850
call s:NetrwRestoreSetting(a:vt."netrw_writekeep","&l:write")
1868-
" call Decho("(s:NetrwOptionsRestore) #10 lines=".&lines)
18691851
call s:NetrwRestoreSetting("s:yykeep","@@")
18701852
" former problem: start with liststyle=0; press <i> : result, following line resets l:ts.
18711853
" Fixed; in s:PerformListing, when w:netrw_liststyle is s:LONGLIST, will use a printf to pad filename with spaces
@@ -1897,28 +1879,17 @@ fun! s:NetrwOptionsRestore(vt)
18971879
endif
18981880
endif
18991881
if has("clipboard") && g:netrw_clipboard
1900-
" call Decho("has clipboard",'~'.expand("<slnum>"))
19011882
call s:NetrwRestoreSetting(a:vt."netrw_starkeep","@*")
19021883
call s:NetrwRestoreSetting(a:vt."netrw_pluskeep","@+")
19031884
endif
19041885
call s:NetrwRestoreSetting(a:vt."netrw_slashkeep","@/")
19051886

1906-
" call Decho("g:netrw_keepdir=".g:netrw_keepdir.": getcwd<".getcwd()."> acd=".&acd,'~'.expand("<slnum>"))
1907-
" call Decho("fo=".&fo.(exists("+acd")? " acd=".&acd : " acd doesn't exist"),'~'.expand("<slnum>"))
1908-
" call Decho("ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)",'~'.expand("<slnum>"))
1909-
" call Decho("diff=".&l:diff." win#".winnr()." w:netrw_diffkeep=".(exists("w:netrw_diffkeep")? w:netrw_diffkeep : "doesn't exist"),'~'.expand("<slnum>"))
1910-
" call Decho("ts=".&l:ts,'~'.expand("<slnum>"))
19111887
" Moved the filetype detect here from NetrwGetFile() because remote files
19121888
" were having their filetype detect-generated settings overwritten by
19131889
" NetrwOptionRestore.
19141890
if &ft != "netrw"
1915-
" call Decho("before: filetype detect (ft=".&ft.")",'~'.expand("<slnum>"))
19161891
filetype detect
1917-
" call Decho("after : filetype detect (ft=".&ft.")",'~'.expand("<slnum>"))
19181892
endif
1919-
" call Decho("(s:NetrwOptionsRestore) lines=".&lines)
1920-
" 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("<slnum>"))
1921-
" call Dret("s:NetrwOptionsRestore : tab#".tabpagenr()." win#".winnr()." buf#".bufnr("%")."<".bufname("%")."> modified=".&modified." modifiable=".&modifiable." readonly=".&readonly)
19221893
endfun
19231894

19241895
" ---------------------------------------------------------------------

0 commit comments

Comments
 (0)