Xavier de Gaye wrote:
> On 01/25/2015 03:59 PM, Bram Moolenaar wrote:
> > Xavier de Gaye wrote:
> >> In the following test case, 'foobar' and 'dummy_file' are two
> >> non-existent files:
> >>
> >> gvim -o foobar dummy_file
> >> :set buftype=nofile
> >> :call append(1, "second line") -> foobar contains now two lines
> >> <CTRL-W> W
> >> :edit foobar -> a) foobar still contains two
> lines
> >> :edit foobar -> b) Ooops... foobar contains no
> lines now !
> >>
> >> The problem is that do_ecmd() does not handle this case in a consistent
> way, whether:
> >> 1) foobar is not curbuf and therefore 'other_file' is true (in case (a)
> above)
> >> 2) or foobar is curbuf and therefore 'other_file' is false (in case (b)
> above) in which case buf_clear_file(curbuf) is invoked by do_ecmd()
> >
> > If you do this with a file then the same thing happens, except that you
> > will get an error at the second ":edit foobar", since the buffer was
> > changed and you are trying to drop the changes.
> >
> > It may seem a bit inconsistant, but changing this will most likely cause
> > some plugins to fail in a weird way. Better just keep it as it is.
>
>
> When the user ':edit' or ':'tabedit' a buffer that is managed by an
> application using netbeans to control the buffer (with the netbeans
> 'editFile' command for example), the buffer may be cleared
> without the knowledge of the application. This is annoying and it is
> the reason why I have submitted this problem.
>
> It may make sense that ':edit' should attempt to reload the buffer
> when it is a file, but it is strange that this command may (or may
> not) clear the buffer when there is no file to reload from, and
> very strange that this behavior depends on the position of the cursor.
Well, I suppose what we could do, without causing too much trouble, is
making ":e foobar" a no-op for a file where 'buftype' is "nofile" and
"foobar" is already the current buffer. It would be unexpected that a
plugin relies on this edit command to make the buffer empty.
I'll make a patch that does it this way, let's see if someone complains.
--
hundred-and-one symptoms of being an internet addict:
119. You are reading a book and look for the scroll bar to get to
the next page.
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
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.