Andy Wokula wrote:
Am 07.02.2010 17:16, schrieb Stahlman Family:
Consider the following test sequence...
:new
:ls
1 #a "[No Name]" line 1
2 %a "[No Name]" line 1
:hide
:ls
1 %a "[No Name]" line 1
2 h "[No Name]" line 0
:new somefile.txt
:ls
1 #a "[No Name]" line 1
2 h "[No Name]" line 0
3 %a "somefile.txt" line 1
As expected, the empty [No Name] buffer created with :new was hidden by
the :hide command and remains in the buffer list. I can get it back in
its own window by executing...
:sb 2
Now consider the following variation on the test sequence above...
:new
:ls
1 #a "[No Name]" line 1
2 %a "[No Name]" line 1
:hide e somefile.txt
:ls
1 a "[No Name]" line 1
2 %a "somefile.txt" line 1
Notice that the [No Name] buffer that used to be buffer 2 is now gone,
apparently replaced by somefile.txt. I can't possibly get it back. I
know it was discarded (and not simply reassigned the name somefile.txt)
because any buffer-local variables it contained are not accessible in
the somefile.txt buffer.
It seems to me that the 2 test cases above should produce similar
results. In particular, I would expect that executing...
:sb 2
...at the end of the second sequence would restore to its own window the
[No Name] buffer hidden by...
:hide e somefile.txt
Is this a bug, or is the behavior described somewhere in the
documentation?
Thanks,
Brett Stahlman
This reminds me of :enew (where it's undocumented, too).
When the current buffer is unnamed and empty ('buftype' doesn't matter),
:enew will reuse its number.
Yes. I first noticed the issue when doing...
:hide enew
...in an empty [No Name] buffer.
What will get lost from the old buffer:
- buffer local variables
- undo history
(99% of unnamed and empty buffers will not have any of them)
Perhaps my case is unusual, but the :enew was used to create a scratch
buffer in the middle of a plugin load sequence, after a bunch of
buf-local variables had been created in the original buffer. I really
needed to go back to the original buffer (after testing something in the
scratch buffer), even if the original buffer happened to be an empty [No
Name] buffer.
This is only what I checked, not a complete list.
I think Vim just tries to be smart and not waste buffer numbers ...
which isusually ok for me.
Perhaps so. If that's the case, though, why doesn't it reclaim one of
the empty [No Name] buffers in case 1 above? It seems inconsistent.
Thanks,
Brett Stahlman
--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php