On 16/04/10 22:47, Marvin Renich wrote:
* James Vega<[email protected]> [100416 11:43]:
On Fri, Apr 16, 2010 at 11:28 AM, Marvin Renich<[email protected]> wrote:
Shouldn't this set curbuf->b_changed based on the "modified" setting
from the swap file, so that if you "recover" a file that was not
modified, you don't set the modified flag?
I'd think that any time you recover from a swap file, the buffer should
be considered "modified". The modified flag indicates that the buffer
is different than the on-disk file with the same name. Whether or not
the buffer was modified at the time that the swap file was last updated
has no bearing on whether the content recovered from the swap file
matches the current contents of the file that was being edited. That's
up to the user to diagnose and decide what steps to take.
Maybe I am missing something. If you are recovering from a swap file,
doesn't Vim read the current version of the file from disk, then apply
the changes that are in the swap file? So, if the swap file has
modified=no, the buffer will match the current version of the file on
disk. Is there something else going on that I have missed?
I haven't tested it, so maybe I misunderstood; but what I understood
from reading the posts was that recovery never sets 'modified'
regardless of whether the swapfile says that the file was modified. OTOH
if you recover the same file twice with the same swapfile, without
editing or deleting it between them, the second recovery will "do
nothing" even if it has "modified:yes" in the swapfile.
I don't think this is a big deal; if you are explicitly recovering, you
probably are paying attention to what you are doing, but then again,
this patch is because people asked to be notified if they try to quit
without saving after recovering.
...Marvin
The reason for recovering is that some people "forget" to save their
changes even after quite a long editing session... and then if there is
a power fail, or an editor crash, it is too late to hit :w<Enter> . Vim,
however, records what it did to the buffer in memory (unless you have
set 'noswapfile') so that will probably be left (except possibly the
last few seconds) even after a crash or a blackout. The problem happens
after restarting Vim, if you recover, hit ZZ (or :xa) to leave Vim, and
then (thinking that your recovery is done) delete the swapfile... only
to find out the next minute that ZZ sent your whole recovery to
never-never land!
If the recovery were to set 'modified', then ZZ (in a Vim with only one
window open) or :xa would write the changes, but (except with
'autowriteall' on of course) :qa would refuse to close, telling you that
you have a modified buffer, and that if you want to forget the changes
then you must add an exclamation mark.
Best regards,
Tony.
--
The Heineken Uncertainty Principle:
You can never be sure how many beers you had last night.
--
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
Subscription settings: http://groups.google.com/group/vim_dev/subscribe?hl=en