NetrwC losing modified buffers

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

NetrwC losing modified buffers

Steven Holt
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?

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: NetrwC losing modified buffers

Justin M. Keyes
Am Di., 3. Juli 2018 um 08:37 Uhr schrieb Steven Holt <[hidden email]>:

>
> 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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: NetrwC losing modified buffers

toothpik
i just :r!ls -AgGl * into a hidden buffer and use gf on the contents

On Tue, Jul 3, 2018 at 7:29 AM, Justin M. Keyes <[hidden email]> wrote:
Am Di., 3. Juli 2018 um 08:37 Uhr schrieb Steven Holt <[hidden email]>:
>
> 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 [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: NetrwC losing modified buffers

Steven Holt
On 03.07.2018 20:56, tooth pik wrote:
> i just :r!ls -AgGl * into a hidden buffer and use gf on the contents
That works if you do it once in a while but when you work with a project
with many directories and have to re/move/preview/edit files all the
time, it provokes violent behaviour.

Dirvish is very close to what I expected from a vim'ish file browser.

On 03.07.2018 15:29, Justin M. Keyes wrote:
> 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.
I don't think so, I have latest stable (?) 8.1 on another machine and it
has the same problem.

> 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.
I like Dirvish philosophy, especially its approach to operating on files
via a visual script (:Shdo, x). But I ran into several problems -
they're below, tell me if we should discuss this directly instead of via
the list.

1. Are preview windows (p) not marked as preview? :pclose and ^W_z do
nothing on them (in netrw they close all preview windows without having
to select them manually).

2. Is there any analog to netrw_chgwin? I like to keep a directory
browser visible in a nearby window, switching to it occasionally to open
a new file (and leaving the directory window be). With netrw (if not for
that nasty bug), it could be accomplished by "setting edit window"
(:NetrwC). I wish there was a similar command in Dirvish that once
called on a window would cause all future files to be opened in that
window rather than in new splits.

3. Opening multiple files (Visual, I) for me opens all but one as hidden
buffers. Visual, O does open them all in splits. For two files, I see
the practical value (one is alternate so you can switch between both),
but how does one use it for 3 and more files?

4. Netrw has a tree listing style (g:netrw_liststyle = 3). Dirvish
claims its buffers are filenames only, but for gf and possibly other
commands leading spaces are removed. Would it be possible to implement a
similar mode with indentation used to indicate directory hierarchy, and
directories can be collapsed/expanded instead of entered?

5. Track of the preview window is lost after any of Dirvish splits were
closed, making p open marked file in the Dirvish window itself rather
than in the existing preview window. Reproduce:

vim
:Dirvish
p
o
(now have 1 Dirvish listing, 1 preview split, 1 file split)
^W^W
:q
(now have 1 Dirvish listing which is focused, 1 preview split)
p
(expected: file opened in the existing preview split)
(actual: Dirvish listing was replaced by the previewed file)

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: NetrwC losing modified buffers

Justin M. Keyes
Am Fr., 6. Juli 2018 um 18:00 Uhr schrieb Steven Holt <[hidden email]>:

>
> On 03.07.2018 20:56, tooth pik wrote:
> > i just :r!ls -AgGl * into a hidden buffer and use gf on the contents
> That works if you do it once in a while but when you work with a project
> with many directories and have to re/move/preview/edit files all the
> time, it provokes violent behaviour.
>
> Dirvish is very close to what I expected from a vim'ish file browser.
>
> On 03.07.2018 15:29, Justin M. Keyes wrote:
> > 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.
> I don't think so, I have latest stable (?) 8.1 on another machine and it
> has the same problem.
>
> > 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.
> I like Dirvish philosophy, especially its approach to operating on files
> via a visual script (:Shdo, x). But I ran into several problems -
> they're below, tell me if we should discuss this directly instead of via
> the list.
>
> 1. Are preview windows (p) not marked as preview? :pclose and ^W_z do
> nothing on them (in netrw they close all preview windows without having
> to select them manually).

Read "p" as "previous window" if that makes more sense. Dirvish
currently doesn't do anything with Vim's preview-window concept. I had
considered it, but decided to keep it dumb. "p" opens in whatever
window you last visited ("previous").

> 2. Is there any analog to netrw_chgwin? I like to keep a directory
> browser visible in a nearby window, switching to it occasionally to open
> a new file (and leaving the directory window be). With netrw (if not for
> that nasty bug), it could be accomplished by "setting edit window"
> (:NetrwC). I wish there was a similar command in Dirvish that once
> called on a window would cause all future files to be opened in that
> window rather than in new splits.

"p", ctrl-n, and ctrl-p serve that purpose in a dumb way. There's no
global "mode", Dirvish doesn't attempt to track that kind of stuff, it
leads to bugs and will always end up disappointing because it means
the plugin must fight Vim. netrw tries to fight Vim and often loses.

> 3. Opening multiple files (Visual, I) for me opens all but one as hidden
> buffers. Visual, O does open them all in splits. For two files, I see
> the practical value (one is alternate so you can switch between both),
> but how does one use it for 3 and more files?

:bnext ? Not sure what else you would expect.

> 4. Netrw has a tree listing style (g:netrw_liststyle = 3). Dirvish
> claims its buffers are filenames only, but for gf and possibly other
> commands leading spaces are removed. Would it be possible to implement a
> similar mode with indentation used to indicate directory hierarchy, and
> directories can be collapsed/expanded instead of entered?

https://github.com/justinmk/vim-dirvish/issues/70

> 5. Track of the preview window is lost after any of Dirvish splits were
> closed, making p open marked file in the Dirvish window itself rather
> than in the existing preview window. Reproduce:

Dirivsh doesn't track anything. "previous", not "preview".

---
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.