diff runtime/autoload/netrw.vim @ 25700:d4faa2c5211b

Update runtime files Commit: https://github.com/vim/vim/commit/89a9c159f23fb7b3e24e6d09068adfc24a73afcb Author: Bram Moolenaar <Bram@vim.org> Date: Sun Aug 29 21:55:35 2021 +0200 Update runtime files
author Bram Moolenaar <Bram@vim.org>
date Sun, 29 Aug 2021 22:00:05 +0200
parents 75ff30a78189
children 11b656e74444
line wrap: on
line diff
--- 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:		Sep 18, 2020
-" Version:	170
+" Date:		Aug 16, 2021
+" Version:	171
 " Maintainer:	Charles E Campbell <NcampObell@SdrPchip.AorgM-NOSPAM>
 " 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 = "v170"
+let g:loaded_netrw = "v171"
 if !exists("s:NOTE")
  let s:NOTE    = 0
  let s:WARNING = 1
@@ -93,7 +93,7 @@ fun! netrw#ErrorMsg(level,msg,errnum)
    else
     let msg= level.a:msg
    endif
-   let s:popuperr_id  = popup_beval(msg,{})
+   let s:popuperr_id  = popup_atcursor(msg,{})
    let s:popuperr_text= ""
  elseif g:netrw_use_errorwindow
    " (default) netrw creates a one-line window to show error/warning
@@ -322,6 +322,7 @@ call s:NetrwInit("g:netrw_banner"      ,
 call s:NetrwInit("g:netrw_browse_split", 0)
 call s:NetrwInit("g:netrw_bufsettings" , "noma nomod nonu nobl nowrap ro nornu")
 call s:NetrwInit("g:netrw_chgwin"      , -1)
+call s:NetrwInit("g:netrw_clipboard"   , 1)
 call s:NetrwInit("g:netrw_compress"    , "gzip")
 call s:NetrwInit("g:netrw_ctags"       , "ctags")
 if exists("g:netrw_cursorline") && !exists("g:netrw_cursor")
@@ -331,6 +332,7 @@ endif
 call s:NetrwInit("g:netrw_cursor"      , 2)
 let s:netrw_usercul = &cursorline
 let s:netrw_usercuc = &cursorcolumn
+"call Decho("(netrw) COMBAK: cuc=".&l:cuc." cul=".&l:cul." initialization of s:netrw_cu[cl]")
 call s:NetrwInit("g:netrw_cygdrive","/cygdrive")
 " Default values - d-g ---------- {{{3
 call s:NetrwInit("s:didstarstar",0)
@@ -703,7 +705,7 @@ fun! netrw#Explore(indx,dosplit,style,..
   endif
 
   " save registers
-  if has("clipboard")
+  if has("clipboard") && g:netrw_clipboard
 "   call Decho("(netrw#Explore) save @* and @+",'~'.expand("<slnum>"))
    sil! let keepregstar = @*
    sil! let keepregplus = @+
@@ -931,7 +933,7 @@ fun! netrw#Explore(indx,dosplit,style,..
 "     call Decho("..case Nexplore with starpat=".starpat.": (indx=".indx.")",'~'.expand("<slnum>"))
      if !exists("w:netrw_explore_list") " sanity check
       NetrwKeepj call netrw#ErrorMsg(s:WARNING,"using Nexplore or <s-down> improperly; see help for netrw-starstar",40)
-      if has("clipboard")
+      if has("clipboard") && g:netrw_clipboard
 "       call Decho("(netrw#Explore) restore @* and @+",'~'.expand("<slnum>"))
        if @* != keepregstar | sil! let @* = keepregstar | endif
        if @+ != keepregplus | sil! let @+ = keepregplus | endif
@@ -957,7 +959,7 @@ fun! netrw#Explore(indx,dosplit,style,..
 "     call Decho("case Pexplore with starpat=".starpat.": (indx=".indx.")",'~'.expand("<slnum>"))
      if !exists("w:netrw_explore_list") " sanity check
       NetrwKeepj call netrw#ErrorMsg(s:WARNING,"using Pexplore or <s-up> improperly; see help for netrw-starstar",41)
-      if has("clipboard")
+      if has("clipboard") && g:netrw_clipboard
 "       call Decho("(netrw#Explore) restore @* and @+",'~'.expand("<slnum>"))
        if @* != keepregstar | sil! let @* = keepregstar | endif
        if @+ != keepregplus | sil! let @+ = keepregplus | endif
@@ -1013,7 +1015,7 @@ fun! netrw#Explore(indx,dosplit,style,..
       catch /^Vim\%((\a\+)\)\=:E480/
        keepalt call netrw#ErrorMsg(s:WARNING,'no files matched pattern<'.pattern.'>',45)
        if &hls | let keepregslash= s:ExplorePatHls(pattern) | endif
-       if has("clipboard")
+       if has("clipboard") && g:netrw_clipboard
 "        call Decho("(netrw#Explore) restore @* and @+",'~'.expand("<slnum>"))
         if @* != keepregstar | sil! let @* = keepregstar | endif
         if @+ != keepregplus | sil! let @+ = keepregplus | endif
@@ -1050,7 +1052,7 @@ fun! netrw#Explore(indx,dosplit,style,..
 
      if w:netrw_explore_listlen == 0 || (w:netrw_explore_listlen == 1 && w:netrw_explore_list[0] =~ '\*\*\/')
       keepalt NetrwKeepj call netrw#ErrorMsg(s:WARNING,"no files matched",42)
-      if has("clipboard")
+      if has("clipboard") && g:netrw_clipboard
 "       call Decho("(netrw#Explore) restore @* and @+",'~'.expand("<slnum>"))
         if @* != keepregstar | sil! let @* = keepregstar | endif
         if @+ != keepregplus | sil! let @+ = keepregplus | endif
@@ -1099,7 +1101,7 @@ fun! netrw#Explore(indx,dosplit,style,..
     if !exists("g:netrw_quiet")
      keepalt NetrwKeepj call netrw#ErrorMsg(s:WARNING,"your vim needs the +path_extra feature for Exploring with **!",44)
     endif
-    if has("clipboard")
+    if has("clipboard") && g:netrw_clipboard
 "     call Decho("(netrw#Explore) restore @* and @+",'~'.expand("<slnum>"))
       if @* != keepregstar | sil! let @* = keepregstar | endif
       if @+ != keepregplus | sil! let @+ = keepregplus | endif
@@ -1173,7 +1175,7 @@ fun! netrw#Explore(indx,dosplit,style,..
   " there's no danger of a late FocusGained event on initialization.
   " Consequently, set s:netrw_events to 2.
   let s:netrw_events= 2
-  if has("clipboard")
+  if has("clipboard") && g:netrw_clipboard
 "   call Decho("(netrw#Explore) restore @* and @+",'~'.expand("<slnum>"))
    if @* != keepregstar | sil! let @* = keepregstar | endif
    if @+ != keepregplus | sil! let @+ = keepregplus | endif
@@ -1641,7 +1643,8 @@ endfun
 fun! s:NetrwOptionsSave(vt)
 "  call Dfunc("s:NetrwOptionsSave(vt<".a:vt.">) win#".winnr()." buf#".bufnr("%")."<".bufname(bufnr("%")).">"." winnr($)=".winnr("$")." mod=".&mod." ma=".&ma)
 "  call Decho(a:vt."netrw_optionsave".(exists("{a:vt}netrw_optionsave")? ("=".{a:vt}netrw_optionsave) : " doesn't exist"),'~'.expand("<slnum>"))
-"  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>"))
+"  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." hid=".&hid,'~'.expand("<slnum>"))
+"  call Decho("(s:NetrwOptionsSave) lines=".&lines)
 
   if !exists("{a:vt}netrw_optionsave")
    let {a:vt}netrw_optionsave= 1
@@ -1667,6 +1670,9 @@ fun! s:NetrwOptionsSave(vt)
   let {a:vt}netrw_cinokeep  = &l:cino
   let {a:vt}netrw_comkeep   = &l:com
   let {a:vt}netrw_cpokeep   = &l:cpo
+  let {a:vt}netrw_cuckeep   = &l:cuc
+  let {a:vt}netrw_culkeep   = &l:cul
+"  call Decho("(s:NetrwOptionsSave) COMBAK: cuc=".&l:cuc." cul=".&l:cul)
   let {a:vt}netrw_diffkeep  = &l:diff
   let {a:vt}netrw_fenkeep   = &l:fen
   if !exists("g:netrw_ffkeep") || g:netrw_ffkeep
@@ -1674,9 +1680,11 @@ 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_hidkeep   = &l:hidden
   let {a:vt}netrw_imkeep    = &l:im
   let {a:vt}netrw_iskkeep   = &l:isk
+  let {a:vt}netrw_lines     = &lines
   let {a:vt}netrw_lskeep    = &l:ls
   let {a:vt}netrw_makeep    = &l:ma
   let {a:vt}netrw_magickeep = &l:magic
@@ -1702,12 +1710,13 @@ fun! s:NetrwOptionsSave(vt)
    let {a:vt}netrw_dirkeep  = getcwd()
 "   call Decho("saving to ".a:vt."netrw_dirkeep<".{a:vt}netrw_dirkeep.">",'~'.expand("<slnum>"))
   endif
-  if has("clipboard")
+  if has("clipboard") && g:netrw_clipboard
    sil! let {a:vt}netrw_starkeep = @*
    sil! let {a:vt}netrw_pluskeep = @+
   endif
   sil! let {a:vt}netrw_slashkeep= @/
 
+"  call Decho("(s:NetrwOptionsSave) 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("<slnum>"))
 "  call Dret("s:NetrwOptionsSave : tab#".tabpagenr()." win#".winnr())
 endfun
@@ -1732,12 +1741,17 @@ fun! s:NetrwOptionsSafe(islocal)
   endif
   call s:NetrwSetSafeSetting("&l:ci",0)
   call s:NetrwSetSafeSetting("&l:cin",0)
-  call s:NetrwSetSafeSetting("&l:bh","hide")
+  if g:netrw_fastbrowse > a:islocal
+   call s:NetrwSetSafeSetting("&l:bh","hide")
+  else
+   call s:NetrwSetSafeSetting("&l:bh","delete")
+  endif
   call s:NetrwSetSafeSetting("&l:cino","")
   call s:NetrwSetSafeSetting("&l:com","")
   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")
   call s:NetrwSetSafeSetting("&l:hid",0)
   call s:NetrwSetSafeSetting("&l:im",0)
   setl isk+=@ isk+=* isk+=/
@@ -1751,7 +1765,10 @@ fun! s:NetrwOptionsSafe(islocal)
   call s:NetrwSetSafeSetting("&l:tw",0)
   call s:NetrwSetSafeSetting("&l:wig","")
   setl cedit&
-  call s:NetrwCursor()
+
+  " set up cuc and cul based on g:netrw_cursor and listing style
+  " COMBAK -- cuc cul related
+  call s:NetrwCursor(0)
 
   " allow the user to override safe options
 "  call Decho("ft<".&ft."> ei=".&ei,'~'.expand("<slnum>"))
@@ -1769,11 +1786,14 @@ endfun
 " s:NetrwOptionsRestore: restore options (based on prior s:NetrwOptionsSave) {{{2
 fun! s:NetrwOptionsRestore(vt)
 "  call Dfunc("s:NetrwOptionsRestore(vt<".a:vt.">) win#".winnr()." buf#".bufnr("%")."<".bufname("%")."> winnr($)=".winnr("$"))
+"  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("<slnum>"))
   if !exists("{a:vt}netrw_optionsave")
 "   call Decho("case ".a:vt."netrw_optionsave : doesn't exist",'~'.expand("<slnum>"))
-"   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>"))
-"   call Decho("ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)",'~'.expand("<slnum>"))
+"   call Decho("..doing filetype detect anyway")
+   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("<slnum>"))
+"   call Decho("..ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)",'~'.expand("<slnum>"))
 "   call Dret("s:NetrwOptionsRestore : ".a:vt."netrw_optionsave doesn't exist")
    return
   endif
@@ -1790,41 +1810,53 @@ fun! s:NetrwOptionsRestore(vt)
     endif
    endif
   endif
+"  call Decho("(s:NetrwOptionsRestore) #1 lines=".&lines)
   call s:NetrwRestoreSetting(a:vt."netrw_aikeep","&l:ai")
   call s:NetrwRestoreSetting(a:vt."netrw_awkeep","&l:aw")
   call s:NetrwRestoreSetting(a:vt."netrw_blkeep","&l:bl")
   call s:NetrwRestoreSetting(a:vt."netrw_btkeep","&l:bt")
   call s:NetrwRestoreSetting(a:vt."netrw_bombkeep","&l:bomb")
+"  call Decho("(s:NetrwOptionsRestore) #2 lines=".&lines)
   call s:NetrwRestoreSetting(a:vt."netrw_cedit","&cedit")
   call s:NetrwRestoreSetting(a:vt."netrw_cikeep","&l:ci")
   call s:NetrwRestoreSetting(a:vt."netrw_cinkeep","&l:cin")
   call s:NetrwRestoreSetting(a:vt."netrw_cinokeep","&l:cino")
   call s:NetrwRestoreSetting(a:vt."netrw_comkeep","&l:com")
+"  call Decho("(s:NetrwOptionsRestore) #3 lines=".&lines)
   call s:NetrwRestoreSetting(a:vt."netrw_cpokeep","&l:cpo")
   call s:NetrwRestoreSetting(a:vt."netrw_diffkeep","&l:diff")
   call s:NetrwRestoreSetting(a:vt."netrw_fenkeep","&l:fen")
   if exists("g:netrw_ffkeep") && g:netrw_ffkeep
    call s:NetrwRestoreSetting(a:vt."netrw_ffkeep")","&l:ff")
   endif
-  call s:NetrwRestoreSetting(a:vt."netrw_fokeep","&l:fo")
-  call s:NetrwRestoreSetting(a:vt."netrw_gdkeep","&l:gd")
-  call s:NetrwRestoreSetting(a:vt."netrw_hidkeep","&l:hidden")
-  call s:NetrwRestoreSetting(a:vt."netrw_imkeep","&l:im")
-  call s:NetrwRestoreSetting(a:vt."netrw_iskkeep","&l:isk")
-  call s:NetrwRestoreSetting(a:vt."netrw_lskeep","&l:ls")
-  call s:NetrwRestoreSetting(a:vt."netrw_makeep","&l:ma")
+"  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_hidkeep"  ,"&l:hidden")
+"  call Decho("(s:NetrwOptionsRestore) #5 lines=".&lines)
+  call s:NetrwRestoreSetting(a:vt."netrw_imkeep"   ,"&l:im")
+  call s:NetrwRestoreSetting(a:vt."netrw_iskkeep"  ,"&l:isk")
+"  call Decho("(s:NetrwOptionsRestore) #6 lines=".&lines)
+  call s:NetrwRestoreSetting(a:vt."netrw_lines"    ,"&lines")
+"  call Decho("(s:NetrwOptionsRestore) #7 lines=".&lines)
+  call s:NetrwRestoreSetting(a:vt."netrw_lskeep"   ,"&l:ls")
+  call s:NetrwRestoreSetting(a:vt."netrw_makeep"   ,"&l:ma")
   call s:NetrwRestoreSetting(a:vt."netrw_magickeep","&l:magic")
-  call s:NetrwRestoreSetting(a:vt."netrw_modkeep","&l:mod")
-  call s:NetrwRestoreSetting(a:vt."netrw_nukeep","&l:nu")
-  call s:NetrwRestoreSetting(a:vt."netrw_rnukeep","&l:rnu")
-  call s:NetrwRestoreSetting(a:vt."netrw_repkeep","&l:report")
-  call s:NetrwRestoreSetting(a:vt."netrw_rokeep","&l:ro")
-  call s:NetrwRestoreSetting(a:vt."netrw_selkeep","&l:sel")
+  call s:NetrwRestoreSetting(a:vt."netrw_modkeep"  ,"&l:mod")
+  call s:NetrwRestoreSetting(a:vt."netrw_nukeep"   ,"&l:nu")
+"  call Decho("(s:NetrwOptionsRestore) #8 lines=".&lines)
+  call s:NetrwRestoreSetting(a:vt."netrw_rnukeep"  ,"&l:rnu")
+  call s:NetrwRestoreSetting(a:vt."netrw_repkeep"  ,"&l:report")
+  call s:NetrwRestoreSetting(a:vt."netrw_rokeep"   ,"&l:ro")
+  call s:NetrwRestoreSetting(a:vt."netrw_selkeep"  ,"&l:sel")
+"  call Decho("(s:NetrwOptionsRestore) #9 lines=".&lines)
   call s:NetrwRestoreSetting(a:vt."netrw_spellkeep","&l:spell")
-  call s:NetrwRestoreSetting(a:vt."netrw_twkeep","&l:tw")
-  call s:NetrwRestoreSetting(a:vt."netrw_wigkeep","&l:wig")
-  call s:NetrwRestoreSetting(a:vt."netrw_wrapkeep","&l:wrap")
+  call s:NetrwRestoreSetting(a:vt."netrw_twkeep"   ,"&l:tw")
+  call s:NetrwRestoreSetting(a:vt."netrw_wigkeep"  ,"&l:wig")
+  call s:NetrwRestoreSetting(a:vt."netrw_wrapkeep" ,"&l:wrap")
   call s:NetrwRestoreSetting(a:vt."netrw_writekeep","&l:write")
+"  call Decho("(s:NetrwOptionsRestore) #10 lines=".&lines)
   call s:NetrwRestoreSetting("s:yykeep","@@")
   " former problem: start with liststyle=0; press <i> : result, following line resets l:ts.
   " Fixed; in s:PerformListing, when w:netrw_liststyle is s:LONGLIST, will use a printf to pad filename with spaces
@@ -1855,7 +1887,7 @@ fun! s:NetrwOptionsRestore(vt)
     unlet {a:vt}netrw_dirkeep
    endif
   endif
-  if has("clipboard")
+  if has("clipboard") && g:netrw_clipboard
 "   call Decho("has clipboard",'~'.expand("<slnum>"))
    call s:NetrwRestoreSetting(a:vt."netrw_starkeep","@*")
    call s:NetrwRestoreSetting(a:vt."netrw_pluskeep","@+")
@@ -1871,9 +1903,11 @@ fun! s:NetrwOptionsRestore(vt)
   " were having their filetype detect-generated settings overwritten by
   " NetrwOptionRestore.
   if &ft != "netrw"
-"   call Decho("filetype detect  (ft=".&ft.")",'~'.expand("<slnum>"))
+"   call Decho("before: filetype detect  (ft=".&ft.")",'~'.expand("<slnum>"))
    filetype detect
-  endif
+"   call Decho("after : filetype detect  (ft=".&ft.")",'~'.expand("<slnum>"))
+  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("<slnum>"))
 "  call Dret("s:NetrwOptionsRestore : tab#".tabpagenr()." win#".winnr()." buf#".bufnr("%")."<".bufname("%")."> modified=".&modified." modifiable=".&modifiable." readonly=".&readonly)
 endfun
@@ -1923,7 +1957,7 @@ fun! s:NetrwRestoreSetting(keepvar,setti
   " typically called from s:NetrwOptionsRestore
   "   call s:NetrwRestoreSettings(keep-option-variable-name,'associated-option')
   "   ex. call s:NetrwRestoreSetting(a:vt."netrw_selkeep","&l:sel")
-  "  Restores option (if different) from a keepvar
+  "  Restores option (but only if different) from a:keepvar
   if exists(a:keepvar)
    exe "let keepvarval= ".a:keepvar
    exe "let setting= ".a:setting
@@ -2845,14 +2879,16 @@ fun! netrw#SetTreetop(iscmd,...)
 "  call Decho("inittreetop<".(exists("inittreetop")? inittreetop : "n/a").">")
 
   if (a:iscmd == 0 || a:1 == "") && exists("inittreetop")
-   let treedir= s:NetrwTreePath(inittreetop)
+   let treedir         = s:NetrwTreePath(inittreetop)
 "   call Decho("treedir<".treedir.">",'~'.expand("<slnum>"))
   else
    if isdirectory(s:NetrwFile(a:1))
 "    call Decho("a:1<".a:1."> is a directory",'~'.expand("<slnum>"))
-    let treedir= a:1
+    let treedir         = a:1
+    let s:netrw_treetop = treedir
    elseif exists("b:netrw_curdir") && (isdirectory(s:NetrwFile(b:netrw_curdir."/".a:1)) || a:1 =~ '^\a\{3,}://')
-    let treedir= b:netrw_curdir."/".a:1
+    let treedir         = b:netrw_curdir."/".a:1
+    let s:netrw_treetop = treedir
 "    call Decho("a:1<".a:1."> is NOT a directory, using treedir<".treedir.">",'~'.expand("<slnum>"))
    else
     " normally the cursor is left in the message window.
@@ -2860,7 +2896,8 @@ fun! netrw#SetTreetop(iscmd,...)
     let netrwbuf= bufnr("%")
     call netrw#ErrorMsg(s:ERROR,"sorry, ".a:1." doesn't seem to be a directory!",95)
     exe bufwinnr(netrwbuf)."wincmd w"
-    let treedir= "."
+    let treedir         = "."
+    let s:netrw_treetop = getcwd()
    endif
   endif
 "  call Decho("treedir<".treedir.">",'~'.expand("<slnum>"))
@@ -4115,6 +4152,7 @@ fun! s:NetrwFileInfo(islocal,fname)
    elseif g:netrw_sizestyle =~# 'h'
     let lsopt= "-lsadh --si"
    endif
+"   call Decho("(s:NetrwFileInfo) lsopt<".lsopt.">")
    if (has("unix") || has("macunix")) && executable("/bin/ls")
 
     if getline(".") == "../"
@@ -4176,9 +4214,10 @@ endfun
 " s:NetrwGetBuffer: [get a new|find an old netrw] buffer for a netrw listing {{{2
 "   returns 0=cleared buffer
 "           1=re-used buffer (buffer not cleared)
+"  Nov 09, 2020: tst952 shows that when user does :set hidden that NetrwGetBuffer will come up with a [No Name] buffer (hid fix)
 fun! s:NetrwGetBuffer(islocal,dirname)
 "  call Dfunc("s:NetrwGetBuffer(islocal=".a:islocal." dirname<".a:dirname.">) liststyle=".g:netrw_liststyle)
-"  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("<slnum>"))
+"  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." hid=".&hid,'~'.expand("<slnum>"))
 "  call Decho("netrwbuf dictionary=".(exists("s:netrwbuf")? string(s:netrwbuf) : 'n/a'),'~'.expand("<slnum>"))
 "  call Dredir("ls!","s:NetrwGetBuffer")
   let dirname= a:dirname
@@ -4228,17 +4267,26 @@ fun! s:NetrwGetBuffer(islocal,dirname)
   endif
 "  call Decho("  bufnum#".bufnum,'~'.expand("<slnum>"))
 
-  " highjack the current buffer if
-  "   it has the desired name
-  "   it is empty
-"  call Decho("deciding if I can highjack the current buffer#".bufnr("%"),'~'.expand("<slnum>"))
-"  call Decho("..dirname<".dirname.">",'~'.expand("<slnum>"))
-"  call Decho("..bufname<".bufname("%").">",'~'.expand("<slnum>"))
-"  call Decho("..getline($)<".getline("$").">",'~'.expand("<slnum>"))
-  if dirname == bufname("%") && line("$") == 1 && getline("%") == ""
+  " highjack the current buffer
+  "   IF the buffer already has the desired name
+  "   AND it is empty
+  let curbuf = bufname("%")
+  if curbuf == '.'
+   let curbuf = getcwd()
+  endif
+"  call Dredir("ls!","NetrwGetFile (renamed buffer back to remote filename<".rfile."> : expand(%)<".expand("%").">)")
+"  call Decho("deciding if netrw may highjack the current buffer#".bufnr("%")."<".curbuf.">",'~'.expand("<slnum>"))
+"  call Decho("..dirname<".dirname.">  IF dirname == bufname",'~'.expand("<slnum>"))
+"  call Decho("..curbuf<".curbuf.">",'~'.expand("<slnum>"))
+"  call Decho("..line($)=".line("$")." AND this is 1",'~'.expand("<slnum>"))
+"  call Decho("..getline(%)<".getline("%").">  AND this line is empty",'~'.expand("<slnum>"))
+  if dirname == curbuf && line("$") == 1 && getline("%") == ""
 "   call Dret("s:NetrwGetBuffer 0<cleared buffer> : highjacking buffer#".bufnr("%"))
    return 0
-  endif
+  else  " DEBUG
+"   call Decho("..did NOT highjack buffer",'~'.expand("<slnum>"))
+  endif
+  " Aug 14, 2021: was thinking about looking for a [No Name] buffer here and using it, but that might cause problems
 
   " get enew buffer and name it -or- re-use buffer {{{3
   if bufnum < 0      " get enew buffer and name it
@@ -4563,7 +4611,7 @@ fun! s:NetrwListStyle(islocal)
   " refresh the listing
 "  call Decho("refresh the listing",'~'.expand("<slnum>"))
   NetrwKeepj call s:NetrwRefresh(a:islocal,s:NetrwBrowseChgDir(a:islocal,'./'))
-  NetrwKeepj call s:NetrwCursor()
+  NetrwKeepj call s:NetrwCursor(0)
 
   " repoint t:netrw_lexbufnr if appropriate
   if exists("repointlexbufnr")
@@ -4769,7 +4817,7 @@ fun! s:NetrwBrowseChgDir(islocal,newdir,
   endif
 "  call Decho("b:netrw_curdir<".b:netrw_curdir.">")
 
-  " NetrwBrowseChgDir: save options and initialize {{{3
+  " NetrwBrowseChgDir; save options and initialize {{{3
 "  call Decho("saving options",'~'.expand("<slnum>"))
   call s:SavePosn(s:netrw_posn)
   NetrwKeepj call s:NetrwOptionsSave("s:")
@@ -4837,6 +4885,8 @@ fun! s:NetrwBrowseChgDir(islocal,newdir,
    if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST && exists("w:netrw_treedict") && newdir !~ '^\(/\|\a:\)'
 "    call Decho("edit-a-file: handle tree listing: w:netrw_treedict<".(exists("w:netrw_treedict")? string(w:netrw_treedict) : 'n/a').">",'~'.expand("<slnum>"))
 "    call Decho("edit-a-file: newdir<".newdir.">",'~'.expand("<slnum>"))
+"    let newdir = s:NetrwTreePath(s:netrw_treetop)
+"    call Decho("edit-a-file: COMBAK why doesn't this recognize file1's directory???")
     let dirname= s:NetrwTreeDir(a:islocal)
     "COMBAK : not working for a symlink -- but what about a regular file? a directory?
 "    call Decho("COMBAK : not working for a symlink -- but what about a regular file? a directory?")
@@ -4950,7 +5000,8 @@ fun! s:NetrwBrowseChgDir(islocal,newdir,
       exe "NetrwKeepj e ".fnameescape(dirname)
      endif
 "     call Decho("edit-a-file: after e! ".dirname.": hidden=".&hidden." bufhidden<".&bufhidden."> mod=".&mod,'~'.expand("<slnum>"))
-     call s:NetrwCursor()
+     " COMBAK -- cuc cul related
+     call s:NetrwCursor(1)
      if &hidden || &bufhidden == "hide"
       " file came from vim's hidden storage.  Don't "restore" options with it.
       let dorestore= 0
@@ -4971,8 +5022,8 @@ fun! s:NetrwBrowseChgDir(islocal,newdir,
      elseif type(g:Netrw_funcref) == 3
 "      call Decho("edit-a-file: handling a list of g:Netrw_funcrefs",'~'.expand("<slnum>"))
       for Fncref in g:Netrw_funcref
-       if type(FncRef) == 2
-        NetrwKeepj call FncRef()
+       if type(Fncref) == 2
+        NetrwKeepj call Fncref()
        endif
       endfor
      endif
@@ -5264,6 +5315,12 @@ fun! netrw#BrowseX(fname,remote)
   endif
 "  call Decho("not a local file nor a webpage request",'~'.expand("<slnum>"))
 
+  if exists("g:netrw_browsex_viewer") && exists("g:netrw_browsex_support_remote") && !g:netrw_browsex_support_remote
+    let remote = a:remote
+  else
+    let remote = 0
+  endif
+
   let ykeep      = @@
   let screenposn = winsaveview()
 "  call Decho("saving posn to screenposn<".string(screenposn).">",'~'.expand("<slnum>"))
@@ -5308,9 +5365,9 @@ fun! netrw#BrowseX(fname,remote)
   endif
 "  call Decho("exten<".exten.">",'~'.expand("<slnum>"))
 
-  if a:remote == 1
+  if remote == 1
    " create a local copy
-"   call Decho("remote: a:remote=".a:remote.": create a local copy of <".a:fname.">",'~'.expand("<slnum>"))
+"   call Decho("remote: remote=".remote.": create a local copy of <".a:fname.">",'~'.expand("<slnum>"))
    setl bh=delete
    call netrw#NetRead(3,a:fname)
    " attempt to rename tempfile
@@ -5332,7 +5389,7 @@ fun! netrw#BrowseX(fname,remote)
     let fname= s:netrw_tmpfile
    endif
   else
-"   call Decho("local: a:remote=".a:remote.": handling local copy of <".a:fname.">",'~'.expand("<slnum>"))
+"   call Decho("local: remote=".remote.": handling local copy of <".a:fname.">",'~'.expand("<slnum>"))
    let fname= a:fname
    " special ~ handler for local
    if fname =~ '^\~' && expand("$HOME") != ""
@@ -5426,8 +5483,8 @@ fun! netrw#BrowseX(fname,remote)
    if a:fname =~ '^https\=://'
     " atril does not appear to understand how to handle html -- so use gvim to edit the document
     let use_ctrlo= 0
-"    call Decho("(COMBAK) fname<".fname.">")
-"    call Decho("(COMBAK) a:fname<".a:fname.">")
+"    call Decho("fname<".fname.">")
+"    call Decho("a:fname<".a:fname.">")
     call s:NetrwExe("sil! !gvim ".fname.' -c "keepj keepalt file '.fnameescape(a:fname).'"')
 
    else
@@ -5475,12 +5532,12 @@ fun! netrw#BrowseX(fname,remote)
   "          return to prior buffer (directory listing)
   "          Feb 12, 2008: had to de-activiate removal of
   "          temporary file because it wasn't getting seen.
-"  if a:remote == 1 && fname != a:fname
+"  if remote == 1 && fname != a:fname
 ""   call Decho("deleting temporary file<".fname.">",'~'.expand("<slnum>"))
 "   call s:NetrwDelete(fname)
 "  endif
 
-  if a:remote == 1
+  if remote == 1
    setl bh=delete bt=nofile
    if g:netrw_use_noswf
     setl noswf
@@ -5539,7 +5596,7 @@ fun! s:NetrwBufRename(newname)
    let b:junk= 1
 "   call Decho("rename buffer: sil! keepj keepalt file ".fnameescape(a:newname),'~'.expand("<slnum>"))
    exe 'sil! keepj keepalt file '.fnameescape(a:newname)
-"   call Dredir("ls!","s:NetrwBufRename (before bwipe)")
+"   call Dredir("ls!","s:NetrwBufRename (before bwipe)~".expand("<slnum>"))
    let oldbufnr= bufnr(oldbufname)
 "   call Decho("oldbufname<".oldbufname."> oldbufnr#".oldbufnr,'~'.expand("<slnum>"))
 "   call Decho("bufnr(%)=".bufnr("%"),'~'.expand("<slnum>"))
@@ -5548,6 +5605,9 @@ fun! s:NetrwBufRename(newname)
     exe "bwipe! ".oldbufnr
 "   else " Decho
 "    call Decho("did *not* bwipe buf#".oldbufnr,'~'.expand("<slnum>"))
+"    call Decho("..reason: if oldbufname<".oldbufname."> is empty",'~'.expand("<slnum>"))"
+"    call Decho("..reason: if oldbufnr#".oldbufnr." is -1",'~'.expand("<slnum>"))"
+"    call Decho("..reason: if oldbufnr#".oldbufnr." != bufnr(%)#".bufnr("%"),'~'.expand("<slnum>"))"
    endif
 "   call Dredir("ls!","s:NetrwBufRename (after rename)")
 "  else " Decho
@@ -6536,7 +6596,7 @@ fun! s:NetrwMaps(islocal)
    if !hasmapto('<Plug>NetrwRefresh')
     nmap <buffer> <unique> <c-l> <Plug>NetrwRefresh
    endif
-   nnoremap <buffer> <silent> <Plug>NetrwRefresh		<c-l>:call <SID>NetrwRefresh(1,<SID>NetrwBrowseChgDir(1,(w:netrw_liststyle == 3)? w:netrw_treetop : './'))<cr>
+   nnoremap <buffer> <silent> <Plug>NetrwRefresh		<c-l>:call <SID>NetrwRefresh(1,<SID>NetrwBrowseChgDir(1,(exists("w:netrw_liststyle") && exists("w:netrw_treetop") && w:netrw_liststyle == 3)? w:netrw_treetop : './'))<cr>
    if s:didstarstar || !mapcheck("<s-down>","n")
     nnoremap <buffer> <silent> <s-down>	:Nexplore<cr>
    endif
@@ -8164,6 +8224,23 @@ fun! s:NetrwOpenFile(islocal)
   call inputsave()
   let fname= input("Enter filename: ")
   call inputrestore()
+"  call Decho("(s:NetrwOpenFile) fname<".fname.">",'~'.expand("<slnum>"))
+
+  " determine if Lexplore is in use
+  if exists("t:netrw_lexbufnr")
+   " check if t:netrw_lexbufnr refers to a netrw window
+"   call Decho("(s:netrwOpenFile) ..t:netrw_lexbufnr=".t:netrw_lexbufnr,'~'.expand("<slnum>"))
+   let lexwinnr = bufwinnr(t:netrw_lexbufnr)
+   if lexwinnr != -1 && exists("g:netrw_chgwin") && g:netrw_chgwin != -1
+"    call Decho("(s:netrwOpenFile) ..Lexplore in use",'~'.expand("<slnum>"))
+    exe "NetrwKeepj keepalt ".g:netrw_chgwin."wincmd w"
+    exe "NetrwKeepj e ".fnameescape(fname)
+    let @@= ykeep
+"    call Dret("s:NetrwOpenFile : creating a file with Lexplore mode")
+   endif
+  endif
+
+  " Does the filename contain a path?
   if fname !~ '[/\\]'
    if exists("b:netrw_curdir")
     if exists("g:netrw_quiet")
@@ -8502,6 +8579,7 @@ fun! s:NetrwPrevWinOpen(islocal)
   let lastwinnr = winnr("$")
   let curword   = s:NetrwGetWord()
   let choice    = 0
+  let s:prevwinopen= 1	" lets s:NetrwTreeDir() know that NetrwPrevWinOpen called it
   let s:treedir = s:NetrwTreeDir(a:islocal)
   let curdir    = s:treedir
 "  call Decho("winnr($)#".lastwinnr." curword<".curword.">",'~'.expand("<slnum>"))
@@ -8829,7 +8907,7 @@ fun! s:NetrwPreview(path) range
     "    0 :             1: top       -- preview window is horizontally split off and on the top
     "    0 :             0: bot       -- preview window is horizontally split off and on the bottom
     "
-    " Note that the file being previewed is already known to not be a directory, hence we can avoid doing a LocalBrowse() check via
+    " Note that the file being previewed is already known to not be a directory, hence we can avoid doing a LocalBrowseCheck() check via
     " the BufEnter event set up in netrwPlugin.vim
 "    call Decho("exe ".(g:netrw_alto? "top " : "bot ").(g:netrw_preview? "vert " : "")."pedit ".fnameescape(a:path),'~'.expand("<slnum>"))
     let eikeep = &ei
@@ -9264,14 +9342,20 @@ fun! s:NetrwTreeDir(islocal)
 "  call Decho("g:netrw_keepdir  =".(exists("g:netrw_keepdir")?   g:netrw_keepdir   : 'n/a'),'~'.expand("<slnum>"))
 "  call Decho("w:netrw_liststyle=".(exists("w:netrw_liststyle")? w:netrw_liststyle : 'n/a'),'~'.expand("<slnum>"))
 "  call Decho("w:netrw_treetop  =".(exists("w:netrw_treetop")?   w:netrw_treetop   : 'n/a'),'~'.expand("<slnum>"))
-
-  if exists("s:treedir")
+"  call Decho("current line<".getline(".").">")
+
+  if exists("s:treedir") && exists("s:prevwinopen")
    " s:NetrwPrevWinOpen opens a "previous" window -- and thus needs to and does call s:NetrwTreeDir early
+"   call Decho('s:NetrwPrevWinOpen opens a "previous" window -- and thus needs to and does call s:NetrwTreeDir early')
    let treedir= s:treedir
    unlet s:treedir
-"   call Dret("s:NetrwTreeDir ".treedir)
+   unlet s:prevwinopen
+"   call Dret("s:NetrwTreeDir ".treedir.": early return since s:treedir existed previously")
    return treedir
   endif
+  if exists("s:prevwinopen")
+   unlet s:prevwinopen
+  endif
 
   if !exists("b:netrw_curdir") || b:netrw_curdir == ""
    let b:netrw_curdir= getcwd()
@@ -9478,20 +9562,29 @@ endfun
 "                     Called by s:PerformListing()
 fun! s:NetrwTreeListing(dirname)
   if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST
-"   call Dfunc("NetrwTreeListing() bufname<".expand("%").">")
+"   call Dfunc("s:NetrwTreeListing() bufname<".expand("%").">")
 "   call Decho("curdir<".a:dirname.">",'~'.expand("<slnum>"))
 "   call Decho("win#".winnr().": w:netrw_treetop ".(exists("w:netrw_treetop")? "exists" : "doesn't exist")." w:netrw_treedict ".(exists("w:netrw_treedict")? "exists" : "doesn't exit"),'~'.expand("<slnum>"))
 "   call Decho("g:netrw_banner=".g:netrw_banner.": banner ".(g:netrw_banner? "enabled" : "suppressed").": (line($)=".line("$")." byte2line(1)=".byte2line(1)." bannercnt=".w:netrw_bannercnt.")",'~'.expand("<slnum>"))
 
    " update the treetop
-"   call Decho("update the treetop",'~'.expand("<slnum>"))
    if !exists("w:netrw_treetop")
+"    call Decho("update the treetop  (w:netrw_treetop doesn't exist yet)",'~'.expand("<slnum>"))
     let w:netrw_treetop= a:dirname
+    let s:netrw_treetop= w:netrw_treetop
 "    call Decho("w:netrw_treetop<".w:netrw_treetop."> (reusing)",'~'.expand("<slnum>"))
    elseif (w:netrw_treetop =~ ('^'.a:dirname) && s:Strlen(a:dirname) < s:Strlen(w:netrw_treetop)) || a:dirname !~ ('^'.w:netrw_treetop)
+"    call Decho("update the treetop  (override w:netrw_treetop with a:dirname<".a:dirname.">)",'~'.expand("<slnum>"))
     let w:netrw_treetop= a:dirname
+    let s:netrw_treetop= w:netrw_treetop
 "    call Decho("w:netrw_treetop<".w:netrw_treetop."> (went up)",'~'.expand("<slnum>"))
    endif
+   if exists("w:netrw_treetop")
+    let s:netrw_treetop= w:netrw_treetop
+   else
+    let w:netrw_treetop= getcwd()
+    let s:netrw_treetop= w:netrw_treetop
+   endif
 
    if !exists("w:netrw_treedict")
     " insure that we have a treedict, albeit empty
@@ -9529,7 +9622,7 @@ fun! s:NetrwTreeListing(dirname)
 
    exe "setl ".g:netrw_bufsettings
 
-"   call Dret("NetrwTreeListing : bufname<".expand("%").">")
+"   call Dret("s:NetrwTreeListing : bufname<".expand("%").">")
    return
   endif
 endfun
@@ -9637,7 +9730,7 @@ fun! s:NetrwWideListing()
    let newcolstart = w:netrw_bannercnt + fpc
    let newcolend   = newcolstart + fpc - 1
 "   call Decho("bannercnt=".w:netrw_bannercnt." fpl=".w:netrw_fpl." fpc=".fpc." newcol[".newcolstart.",".newcolend."]",'~'.expand("<slnum>"))
-   if has("clipboard")
+   if has("clipboard") && g:netrw_clipboard
 "    call Decho("(s:NetrwWideListing) save @* and @+",'~'.expand("<slnum>"))
     sil! let keepregstar = @*
     sil! let keepregplus = @+
@@ -10683,7 +10776,7 @@ endfun
 " ---------------------------------------------------------------------
 " netrw#LocalBrowseCheck: {{{2
 fun! netrw#LocalBrowseCheck(dirname)
-  " This function is called by netrwPlugin.vim's s:LocalBrowse(), s:NetrwRexplore(),
+  " This function is called by netrwPlugin.vim's s:LocalBrowseCheck(), s:NetrwRexplore(),
   " and by <cr> when atop a listed file/directory (via a buffer-local map)
   "
   " unfortunate interaction -- split window debugging can't be used here, must use
@@ -10834,7 +10927,7 @@ endfun
 "  Hiding   a buffer means that it will be re-used   when examined, hence "fast".
 "                       (re-using a buffer may not be as accurate)
 "
-"  s:netrw_events : doesn't exist, s:LocalFastBrowser() will install autocmds whena med or fast browsing
+"  s:netrw_events : doesn't exist, s:LocalFastBrowser() will install autocmds with medium-speed or fast browsing
 "                   =1: autocmds installed, but ignore next FocusGained event to avoid initial double-refresh of listing.
 "                       BufEnter may be first event, then a FocusGained event.  Ignore the first FocusGained event.
 "                       If :Explore used: it sets s:netrw_events to 2, so no FocusGained events are ignored.
@@ -10996,13 +11089,14 @@ fun! s:LocalListing()
      let sz= s:NetrwHumanReadable(sz)
     endif
     let longfile= printf("%-".(g:netrw_maxfilenamelen+1)."s",pfile)
-    let pfile   = longfile.fsz." ".strftime(g:netrw_timefmt,getftime(filename))
+    let pfile   = longfile.sz." ".strftime(g:netrw_timefmt,getftime(filename))
 "    call Decho("longlist support: sz=".sz." fsz=".fsz,'~'.expand("<slnum>"))
    endif
 
    if     g:netrw_sort_by =~# "^t"
     " sort by time (handles time up to 1 quintillion seconds, US)
     " Decorate listing by prepending a timestamp/  .  Sorting will then be done based on time.
+"    call Decho("implementing g:netrw_sort_by=".g:netrw_sort_by." (time)")
 "    call Decho("getftime(".filename.")=".getftime(filename),'~'.expand("<slnum>"))
     let t  = getftime(filename)
     let ft = strpart("000000000000000000",1,18-strlen(t)).t
@@ -11012,6 +11106,7 @@ fun! s:LocalListing()
 
    elseif g:netrw_sort_by =~ "^s"
     " sort by size (handles file sizes up to 1 quintillion bytes, US)
+"    call Decho("implementing g:netrw_sort_by=".g:netrw_sort_by." (size)")
 "    call Decho("getfsize(".filename.")=".getfsize(filename),'~'.expand("<slnum>"))
     let sz   = getfsize(filename)
     if g:netrw_sizestyle =~# "[hH]"
@@ -11024,6 +11119,7 @@ fun! s:LocalListing()
 
    else
     " sort by name
+"    call Decho("implementing g:netrw_sort_by=".g:netrw_sort_by." (name)")
 "    call Decho("exe NetrwKeepj put ='".pfile."'",'~'.expand("<slnum>"))
     sil! NetrwKeepj put=pfile
    endif
@@ -11746,19 +11842,32 @@ endfun
 
 " ---------------------------------------------------------------------
 " s:NetrwCursor: responsible for setting cursorline/cursorcolumn based upon g:netrw_cursor {{{2
-fun! s:NetrwCursor()
+fun! s:NetrwCursor(editfile)
   if !exists("w:netrw_liststyle")
    let w:netrw_liststyle= g:netrw_liststyle
   endif
 "  call Dfunc("s:NetrwCursor() ft<".&ft."> liststyle=".w:netrw_liststyle." g:netrw_cursor=".g:netrw_cursor." s:netrw_usercuc=".s:netrw_usercuc." s:netrw_usercul=".s:netrw_usercul)
 
+"  call Decho("(s:NetrwCursor) COMBAK: cuc=".&l:cuc." cul=".&l:cul)
+
   if &ft != "netrw"
    " if the current window isn't a netrw directory listing window, then use user cursorline/column
    " settings.  Affects when netrw is used to read/write a file using scp/ftp/etc.
 "   call Decho("case ft!=netrw: use user cul,cuc",'~'.expand("<slnum>"))
-   let &l:cursorline   = s:netrw_usercul
-   let &l:cursorcolumn = s:netrw_usercuc
-
+
+  elseif g:netrw_cursor == 8
+   if w:netrw_liststyle == s:WIDELIST
+    setl cursorline
+    setl cursorcolumn
+   else
+    setl cursorline
+   endif
+  elseif g:netrw_cursor == 7
+    setl cursorline
+  elseif g:netrw_cursor == 6
+   if w:netrw_liststyle == s:WIDELIST
+    setl cursorline
+   endif
   elseif g:netrw_cursor == 4
    " all styles: cursorline, cursorcolumn
 "   call Decho("case g:netrw_cursor==4: setl cul cuc",'~'.expand("<slnum>"))
@@ -11775,26 +11884,22 @@ fun! s:NetrwCursor()
    else
 "    call Decho("case g:netrw_cursor==3 and not wide: setl cul (use user's cuc)",'~'.expand("<slnum>"))
     setl cursorline
-    let &l:cursorcolumn   = s:netrw_usercuc
    endif
 
   elseif g:netrw_cursor == 2
    " thin-long-tree: cursorline, user's cursorcolumn
    " wide          : cursorline, user's cursorcolumn
 "   call Decho("case g:netrw_cursor==2: setl cuc (use user's cul)",'~'.expand("<slnum>"))
-   let &l:cursorcolumn = s:netrw_usercuc
    setl cursorline
 
   elseif g:netrw_cursor == 1
    " thin-long-tree: user's cursorline, user's cursorcolumn
    " wide          : cursorline,        user's cursorcolumn
-   let &l:cursorcolumn = s:netrw_usercuc
    if w:netrw_liststyle == s:WIDELIST
 "    call Decho("case g:netrw_cursor==2 and wide: setl cul (use user's cuc)",'~'.expand("<slnum>"))
     setl cursorline
    else
 "    call Decho("case g:netrw_cursor==2 and not wide: (use user's cul,cuc)",'~'.expand("<slnum>"))
-    let &l:cursorline   = s:netrw_usercul
    endif
 
   else
@@ -11804,6 +11909,7 @@ fun! s:NetrwCursor()
    let &l:cursorcolumn = s:netrw_usercuc
   endif
 
+" call Decho("(s:NetrwCursor) COMBAK: cuc=".&l:cuc." cul=".&l:cul)
 "  call Dret("s:NetrwCursor : l:cursorline=".&l:cursorline." l:cursorcolumn=".&l:cursorcolumn)
 endfun
 
@@ -11817,6 +11923,7 @@ fun! s:RestoreCursorline()
   if exists("s:netrw_usercuc")
    let &l:cursorcolumn = s:netrw_usercuc
   endif
+"  call Decho("(s:RestoreCursorline) COMBAK: cuc=".&l:cuc." cul=".&l:cul)
 "  call Dret("s:RestoreCursorline : restored cul=".&l:cursorline." cuc=".&l:cursorcolumn)
 endfun
 
@@ -11852,11 +11959,37 @@ fun! s:NetrwDelete(path)
 endfun
 
 " ---------------------------------------------------------------------
+" s:NetrwBufRemover: removes a buffer that: {{{2s
+"                    has buffer-id > 1
+"                    is unlisted
+"                    is unnamed
+"                    does not appear in any window
+fun! s:NetrwBufRemover(bufid)
+"  call Dfunc("s:NetrwBufRemover(".a:bufid.")")
+"  call Decho("buf#".a:bufid."           ".((a:bufid > 1)? ">" : "≯")." must be >1 for removal","~".expand("<slnum>"))
+"  call Decho("buf#".a:bufid." is        ".(buflisted(a:bufid)? "listed" : "unlisted"),"~".expand("<slnum>"))
+"  call Decho("buf#".a:bufid." has name <".bufname(a:bufid).">","~".expand("<slnum>"))
+"  call Decho("buf#".a:bufid." has winid#".bufwinid(a:bufid),"~".expand("<slnum>"))
+
+  if a:bufid > 1 && !buflisted(a:bufid) && bufname(a:bufid) == "" && bufwinid(a:bufid) == -1
+"   call Decho("(s:NetrwBufRemover) removing buffer#".a:bufid,"~".expand("<slnum>"))
+   exe "bd! ".a:bufid
+  endif
+
+"  call Dret("s:NetrwBufRemover")
+endfun
+
+" ---------------------------------------------------------------------
 " s:NetrwEnew: opens a new buffer, passes netrw buffer variables through {{{2
 fun! s:NetrwEnew(...)
 "  call Dfunc("s:NetrwEnew() a:0=".a:0." win#".winnr()." winnr($)=".winnr("$")." bufnr($)=".bufnr("$")." expand(%)<".expand("%").">")
 "  call Decho("curdir<".((a:0>0)? a:1 : "")."> buf#".bufnr("%")."<".bufname("%").">",'~'.expand("<slnum>"))
 
+  " Clean out the last buffer: 
+  " Check if the last buffer has # > 1, is unlisted, is unnamed, and does not appear in a window
+  " If so, delete it.
+  call s:NetrwBufRemover(bufnr("$"))
+
   " grab a function-local-variable copy of buffer variables
 "  call Decho("make function-local copy of netrw variables",'~'.expand("<slnum>"))
   if exists("b:netrw_bannercnt")      |let netrw_bannercnt       = b:netrw_bannercnt      |endif