build latest master with default configure options
set minimal vimrc
set nocompatible
let g:netrw_liststyle=3
~/a
└── b
├── c
├── c2
└── c3
└── d
:Lexplore a
../
a/
| b/
| | c/
| | c2/
| | c3/
| | | d/
De-select the terminal (lose focus)
Select vim again (regain focus)
See this (header omitted again):
../
a/
| b/
| | c
| | c2
| | c3
(Clicking those folders without slashes opens another netrw view with that folder as root - but that part is, in that broken state, technically correct I would say)
Note: it only happens when you are "3 folders deep" - without opening 'd' it does not break.
Note2: Closing and re-opening folder 'b' "fixes" it - until the next focus lost/regain cycle.
Folders should not lose their trailing slash or vanish :)
8.2.4424
Tested on Darwin arm (macos 12.2.1) and Ubuntu 21.04
xterm-256color
zsh 5.8
No response
—
Reply to this email directly, view it on GitHub.
Triage notifications on the go with GitHub Mobile for iOS or Android.
You are receiving this because you are subscribed to this thread.![]()
Is this likely to be looked at any time soon?
This has been a persistent issue with my workflow for a good while now, and is getting to the point where discarding netrw in favour of NERDtree maximalism is the only sane way to explore my source tree from within vim.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
ping @cecamp
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
Hey,
(This has been on my list for a while, I remember encountering this a couple of years ago
when getting into Vim and trying to get it to look like my IDE at that time.)
Seems there is an issue in the glob wrapper used to refresh the tree after focus is regained: NetrwGlob.
When a pattern matches a folder, (in this case '*') it is returned without a trailing slash.
However, we expect the slash to be there when iterating entries to render subfolders here.
Following the original example:
all c*/ subfolders become c* (no slash) in the dictionary after refresh, causing them to be treated as files.
For the initial example, initial dictionary entries are:
{'a/b/c3': ['d/'], 'a': ['b/'], 'a/b': ['c/', 'c2/', 'c3/']}
And after a refresh we get:
{'a/b/c3': ['d/'], 'a': ['b/'], 'a/b': ['c', 'c2', 'c3', '.', '..']}
I'm pretty out of touch with Vim script (and source) but, to be more clear, a naive patch addressing it may look like this:
(parent folder substitution needs a small tweak to handle trailing slashes)
diff --git a/runtime/autoload/netrw.vim b/runtime/autoload/netrw.vim index 1372de4df..c4870ce3c 100644 --- a/runtime/autoload/netrw.vim +++ b/runtime/autoload/netrw.vim @@ -5821,13 +5821,16 @@ fun! s:NetrwGlob(direntry,expr,pare) let w:netrw_liststyle= keep_liststyle elseif v:version > 704 || (v:version == 704 && has("patch656")) let filelist= glob(s:ComposePath(fnameescape(a:direntry),a:expr),0,1,1) + let filelist = map(filelist, 'isdirectory(v:val) && v:val !~ "\\.\\.$" && v:val !~ "\\.$" ? v:val . "/" : v:val') if a:pare - let filelist= map(filelist,'substitute(v:val, "^.*/", "", "")') + let parentdir=fnameescape(a:direntry).'/' + let filelist= map(filelist,'substitute(v:val, parentdir, "", "")') endif else let filelist= glob(s:ComposePath(fnameescape(a:direntry),a:expr),0,1) if a:pare - let filelist= map(filelist,'substitute(v:val, "^.*/", "", "")') + let parentdir=fnameescape(a:direntry).'/' + let filelist= map(filelist,'substitute(v:val, parentdir, "", "")') endif endif " call Dret("s:NetrwGlob ".string(filelist))
Two things that may be worth mentioning but not entirely related:
glob() returns the list sorted alphabetically (without slashes), so re-sorting may be need (subtree b/ a c will change to a b/ c after a refresh)Let me know if I can help with anything!
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
Hmm, with my usual options I don't see that misbehavior; I have to run it without my .vimrc to see it. I'll look into it further.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
First finding: the option I use which prevents the issue is:
let g:netrw_fastbrowse= 2
That shouldn't be a problem for the normal setting, so I'll look into it further, but at least you can use that setting for now.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
First finding: the option I use which prevents the issue is:
let g:netrw_fastbrowse= 2
Great!
Just a heads up: seems to still be reproducible with let g:netrw_fastbrowse= 2 if we
follow the original report until step 6 and instead of changing focus, we force a refresh with ctrl-L.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
My two cents:
Instead of tweaking s:NetrwGlob(), f_glob() itself technically has a WILD_ADD_SLASH flag, which I think may be cleaner and solves a big part of the issue - though, it would probably have to be add as another parameter to glob().
The sorting of glob is very much an issue: if you have any g:netrw_sort_sequence set, the glob will alter and break the order.
Unfortunately I fail to create any combination of hackery to re-sort the tree after the globbing produced by a refresh.
(I was toying around with s:NetrwSetSort and the exe '$sort [...] but I am clearly doing something wrong - netrw is a complex beast)
Lastly, and this is 100% pebcac: the fastbrowse= 2 option is no solution for me, since I have to be able to refresh the list, due to some other hackery in my config.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
Closed #9807 as completed via 64a536d.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()