On Mon, Jul 18, 2016 at 12:29 AM, Michal Grochmal <[email protected]> wrote: > Hello, > > Apologies if this email bounces several times, it is my first time using > googlegroups. And I am struggling with their we interface. > > I believe I found a bug in the runtime/autoload/netrw.vim script (the > path is based on the repository structure). Since `netrw` is a script > originally by DrChip he is also included in the email.
Right. > > The issue happens when I open Vim with the following configuration > (.vimrc): > > " 3 is tree listing > let g:netrw_liststyle=3 > let g:netrw_chgwin=2 > let g:netrw_winsize=22 > > After opening Vim I perform: > > :Lexplore > > To open `netrw` and finally press `r` to reorder the tree listing. I > then use `:buffers!` to look at the hidden buffers created and see this: > > 1 #a "[No Name]" line 1 > 2u h + "NetrwTreeListing 1" line 1 > 4u%a- "NetrwTreeListing 2" line 8 > 5u "NetrwTreeListing" line 1 > > Buffer no. 2 is marked as modified which makes Vim write the file if I > perform `:wall`. The same happens with the `R` (rename) and `D` > (delete) commands. > > After a while I end with dozens of `NetrwTreeListing *` files in the > current directory (I use `:wall` often). > > This does not happen if I change `g:netrw_liststyle` to any other value, > i.e. the bug is specific to the tree listing. > > I have seen this behaviour using the `netrw.vim` script shipped with Vim: > https://github.com/vim/vim/blob/master/runtime/autoload/netrw.vim > > And also within the `netrw.vim` script available in the Vimball on > DrChip's page: > http://www.drchip.org/astronaut/vim/#NETRW > > The investigation into this bug sprouted from a question on the vim > stack exchange: > http://vi.stackexchange.com/questions/8839/how-i-configure-vim-for-use-with-netrw > > ------ > > I believe I have tracked the bug and a patch is attached. Although I > believe that my solution is ugly and not the best one by far. I only > learned Vimscript some two month ago. > > In the routine `s:NetrwRefresh(islocal,dirname)` I found that commenting > the following lines stopped the modified buffer from being generated: > > sil! NetrwKeepj %d _ > if a:islocal > NetrwKeepj call netrw#LocalBrowseCheck(a:dirname) > else > NetrwKeepj call s:NetrwBrowse(a:islocal,a:dirname) > endif > > Therefore I managed to come up with the following solution: > > sil! NetrwKeepj %d _ > setl nomod > if a:islocal > NetrwKeepj call netrw#LocalBrowseCheck(a:dirname) > setl nomod > else > NetrwKeepj call s:NetrwBrowse(a:islocal,a:dirname) > setl nomod > endif > > I have tested it, and the buffer is now correctly generated but the > modified flag is not set anymore. In essence, now all `NetrwTreeLisitng > *` buffers remain in unmodified state and are not written when I call > `:wall`. > > (Adding a single `setl nomod` after the `endif` does not appear to > work.) > > The patch attached contains this exact solution. It works. Yet, I > repeat, I'm not confident in my skills at editing Vimscript, and the > existence of a better solution is very likely. > > Can I ask for your input on this change? > > Thanks, > -- > Mike Grochmal > key ID 0xC840C4F6 Which netrw version were you using to generate you patch? The one from Dr. Chip's Astronaut site maybe? In that case it is indeed the most recent one but you ought to have mentioned the version number found near the top of the file. In the current "stable" version (156, dated 20 Apr 2016, as distributed with Vim 7.4.2066) I find your "line 8499" at line 8465 i.e. more than 30 lines higher. Best regards, Tony. -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
