Christian Brabandt wrote:

> On Do, 15 Apr 2010, Tony Mechelynck wrote:
> 
> [...]
> > After recovering, you should check the results, and, if correct, do a  
> > "forced write" with :w or :wq (not ZZ :x :wa or :xa). But IMHO if the  
> > recovery modifies the buffer (i.e. makes it different from the file on  
> > disk), it should also set the local 'modified' option.
> 
> This has come up on the vim_use mailinglist. The problem seems to be
> that after recovery of a swap buffer, the file should be modified so you
> are not loosing your changes after e.g. accidently hitting ZZ
> 
> Signed-off-by: Christian Brabandt <c...@256bit.org>
> ---
>  src/memline.c |    1 +
>  1 files changed, 1 insertions(+), 0 deletions(-)
> 
> diff --git a/src/memline.c b/src/memline.c
> index 102b61e..c4a0d87 100644
> --- a/src/memline.c
> +++ b/src/memline.c
> @@ -1326,6 +1326,7 @@ ml_recover()
>       * the buffer. Delete it.
>       */
>      ml_delete(curbuf->b_ml.ml_line_count, FALSE);
> +    curbuf->b_changed = TRUE;
>      curbuf->b_flags |= BF_RECOVERED;
>  
>      recoverymode = FALSE;

After reading the other messages in this thread, I think the best
solution is to only mark the buffer as changed if it actually differs
from the file on disk.

Setting the flag always is too different from the current behavior.
Never setting the flag has the danger of "ZZ" dropping the changes
without the user giving a hint about that.

Perhaps the code in buf_contents_changed() can be used to check if the
recovered file differs from the file on disk.  Or perhaps making a copy
of the buffer before recovering would work.

-- 
How To Keep A Healthy Level Of Insanity:
5. Put decaf in the coffee maker for 3 weeks. Once everyone has gotten
   over their caffeine addictions, switch to espresso.

 /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\        download, build and distribute -- http://www.A-A-P.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
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

Reply via email to