Tuesday, July 3, 2018

Re: NetrwC losing modified buffers

Am Di., 3. Juli 2018 um 08:37 Uhr schrieb Steven Holt <spolnoga@mailhouse.biz>:
>
> I know this isn't an official netrw mailinglist but I have contacted
> DrChip about this matter and got no response. I hope someone from this
> list has any pointers related to this issue.
>
> I have faced a seriously daunting problem with one of netrw functions,
> yet it's so trivial that it makes me think I'm doing something wrong.
> The help text has (almost) nothing on this subject and I couldn't google
> anything related either.
>
> The only distantly related item from netrw FAQ is P17 and it suggests
> disabling vim's autochdir but I don't have it enabled.
>
> I have checked this issue on 2 different distros and vim versions, with
> stock netrw and one from drchip.org - results are the same.
>
> In a nutshell: netrw respects neither buffer-related settings (hidden,
> autowrite/all) nor buffer states (modified) when netrw_chgwin is not -1
> - it just silently reloads (!) the buffer in the target window.
>
> My scenario: I am used to have autowriteall and/or hidden enabled.
> Whenever I open a new file (via :e or other means), vim writes it
> automatically or hides it - in any case, the buffer is still safe,
> either saved to disk or still dirty as one of the hidden buffers.
>
> With chgwin, netrw can be used as a file browser which doesn't produce
> new windows for every file I'm opening, instead using my designated
> window for new files. I expect that when I try to open a buffer from
> netrw with chgwin *not* set to -1, it asks me about the buffer in that
> window, saves it automatically or hides it, if that buffer is dirty.
>
> Last thing I expect is netrw forcefully discarding it and reloading as
> if I did ":e!", yet that's what it does.
>
> Steps to reproduce:
>
> - make 2 panels
> - load netrw in one
> - load a file in another and netrw_chgwin to it
> - do modifications to the file
> - return to netrw and load the same file - your changes are gone
>
> :version (on Ubuntu)
> VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Nov 24 2016 16:44:48)
> Included patches: 1-1689
> Extra patches: 8.0.0056
>
> cd /tmp
> (from :help netrw-debug)
> echo >>netrw.vimrc set nocompatible
> echo >>netrw.vimrc so $HOME/.vim/plugin/netrwPlugin.vim
> vim -u netrw.vimrc --noplugins -i NONE
> :sp
> :e .
> ^W^W
> :NetrwC
> ^W^W
> (select some file and Enter to open it)
> (do some modifications in it)
> ^W^W
> (press Enter on the same file)
> (file is reloaded, changes lost)
>
> Is this by design?

One may be forgiven for thinking that netrw was designed to lose data,
but no, I don't think it was intentional. That particular bug, I
think, was fixed in more recent versions of Vim.

But other subtle, pernicious bugs still exist in netrw since 2012 or
longer. It's difficult to fix them because netrw is too complicated
(eleven-thousand lines of Vim script).

netrw drove me crazy enough to create
https://github.com/justinmk/vim-dirvish , which focuses on reliability
and harmony with Vi/Vim idioms.

---
Justin M. Keyes

--
--
You received this message from the "vim_use" 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_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: