Thanks!
Just for the record, and to answer the question I asked in the thread:
I think that a repeatable :diffoff (as in this patch) makes more sense.
If :diffoff only worked once after diff mode was entered, it would not
destroy user settings.
But always returning diff settings back to safed "sane" settings (rather
than to one-size-fits-all defaults, when :diffoff is repeated) is
probably more useful. Esp. because only settings are touched that look
like they are left over from diff mode. So it is not too destructive.
This is a repeatable :diffoff that "carefully backs out of diff mode".
On 03-Jul-15, Bram Moolenaar wrote:
>
> Patch 7.4.768
> Problem: :diffoff only works properly once.
> Solution: Also make :diffoff work when used a second time. (Olaf Dabrunz)
> Files: src/diff.c
>
>
> *** ../vim-7.4.767/src/diff.c 2015-03-31 13:33:00.781525085 +0200
> --- src/diff.c 2015-07-03 14:55:54.953220651 +0200
> ***************
> *** 1138,1169 ****
> curwin = old_curwin;
> # endif
>
> - wp->w_p_diff = TRUE;
> -
> /* Use 'scrollbind' and 'cursorbind' when available */
> #ifdef FEAT_SCROLLBIND
> ! if (!wp->w_p_diff_saved)
> wp->w_p_scb_save = wp->w_p_scb;
> wp->w_p_scb = TRUE;
> #endif
> #ifdef FEAT_CURSORBIND
> ! if (!wp->w_p_diff_saved)
> wp->w_p_crb_save = wp->w_p_crb;
> wp->w_p_crb = TRUE;
> #endif
> ! if (!wp->w_p_diff_saved)
> wp->w_p_wrap_save = wp->w_p_wrap;
> wp->w_p_wrap = FALSE;
> # ifdef FEAT_FOLDING
> curwin = wp;
> curbuf = curwin->w_buffer;
> ! if (!wp->w_p_diff_saved)
> wp->w_p_fdm_save = vim_strsave(wp->w_p_fdm);
> set_string_option_direct((char_u *)"fdm", -1, (char_u *)"diff",
> OPT_LOCAL|OPT_FREE, 0);
> curwin = old_curwin;
> curbuf = curwin->w_buffer;
> ! if (!wp->w_p_diff_saved)
> {
> wp->w_p_fdc_save = wp->w_p_fdc;
> wp->w_p_fen_save = wp->w_p_fen;
> --- 1138,1171 ----
> curwin = old_curwin;
> # endif
>
> /* Use 'scrollbind' and 'cursorbind' when available */
> #ifdef FEAT_SCROLLBIND
> ! if (!wp->w_p_diff)
> wp->w_p_scb_save = wp->w_p_scb;
> wp->w_p_scb = TRUE;
> #endif
> #ifdef FEAT_CURSORBIND
> ! if (!wp->w_p_diff)
> wp->w_p_crb_save = wp->w_p_crb;
> wp->w_p_crb = TRUE;
> #endif
> ! if (!wp->w_p_diff)
> wp->w_p_wrap_save = wp->w_p_wrap;
> wp->w_p_wrap = FALSE;
> # ifdef FEAT_FOLDING
> curwin = wp;
> curbuf = curwin->w_buffer;
> ! if (!wp->w_p_diff)
> ! {
> ! if (wp->w_p_diff_saved)
> ! free_string_option(wp->w_p_fdm_save);
> wp->w_p_fdm_save = vim_strsave(wp->w_p_fdm);
> + }
> set_string_option_direct((char_u *)"fdm", -1, (char_u *)"diff",
> OPT_LOCAL|OPT_FREE, 0);
> curwin = old_curwin;
> curbuf = curwin->w_buffer;
> ! if (!wp->w_p_diff)
> {
> wp->w_p_fdc_save = wp->w_p_fdc;
> wp->w_p_fen_save = wp->w_p_fen;
> ***************
> *** 1183,1188 ****
> --- 1185,1192 ----
> /* Saved the current values, to be restored in ex_diffoff(). */
> wp->w_p_diff_saved = TRUE;
>
> + wp->w_p_diff = TRUE;
> +
> if (addbuf)
> diff_buf_add(wp->w_buffer);
> redraw_win_later(wp, NOT_VALID);
> ***************
> *** 1197,1203 ****
> exarg_T *eap;
> {
> win_T *wp;
> - win_T *old_curwin = curwin;
> #ifdef FEAT_SCROLLBIND
> int diffwin = FALSE;
> #endif
> --- 1201,1206 ----
> ***************
> *** 1206,1262 ****
> {
> if (eap->forceit ? wp->w_p_diff : wp == curwin)
> {
> ! /* Set 'diff', 'scrollbind' off and 'wrap' on. If option values
> ! * were saved in diff_win_options() restore them. */
> wp->w_p_diff = FALSE;
>
> #ifdef FEAT_SCROLLBIND
> ! if (wp->w_p_scb)
> ! wp->w_p_scb = wp->w_p_diff_saved ? wp->w_p_scb_save : FALSE;
> #endif
> #ifdef FEAT_CURSORBIND
> ! if (wp->w_p_crb)
> ! wp->w_p_crb = wp->w_p_diff_saved ? wp->w_p_crb_save : FALSE;
> #endif
> ! if (!wp->w_p_wrap)
> ! wp->w_p_wrap = wp->w_p_diff_saved ? wp->w_p_wrap_save : TRUE;
> #ifdef FEAT_FOLDING
> - curwin = wp;
> - curbuf = curwin->w_buffer;
> - if (wp->w_p_diff_saved)
> - {
> free_string_option(wp->w_p_fdm);
> ! wp->w_p_fdm = wp->w_p_fdm_save;
> ! wp->w_p_fdm_save = empty_option;
> ! }
> ! else
> ! set_string_option_direct((char_u *)"fdm", -1,
> ! (char_u *)"manual", OPT_LOCAL|OPT_FREE, 0);
> ! curwin = old_curwin;
> ! curbuf = curwin->w_buffer;
> ! if (wp->w_p_fdc == diff_foldcolumn)
> ! wp->w_p_fdc = wp->w_p_diff_saved ? wp->w_p_fdc_save : 0;
> ! if (wp->w_p_fdl == 0 && wp->w_p_diff_saved)
> ! wp->w_p_fdl = wp->w_p_fdl_save;
>
> - if (wp->w_p_fen)
> - {
> /* Only restore 'foldenable' when 'foldmethod' is not
> * "manual", otherwise we continue to show the diff folds. */
> ! if (foldmethodIsManual(wp) || !wp->w_p_diff_saved)
> ! wp->w_p_fen = FALSE;
> ! else
> ! wp->w_p_fen = wp->w_p_fen_save;
> }
>
> - foldUpdateAll(wp);
> - /* make sure topline is not halfway a fold */
> - changed_window_setting_win(wp);
> - #endif
> /* Note: 'sbo' is not restored, it's a global option. */
> diff_buf_adjust(wp);
> -
> - wp->w_p_diff_saved = FALSE;
> }
> #ifdef FEAT_SCROLLBIND
> diffwin |= wp->w_p_diff;
> --- 1209,1255 ----
> {
> if (eap->forceit ? wp->w_p_diff : wp == curwin)
> {
> ! /* Set 'diff' off. If option values were saved in
> ! * diff_win_options(), restore the ones whose settings seem to have
> ! * been left over from diff mode. */
> wp->w_p_diff = FALSE;
>
> + if (wp->w_p_diff_saved)
> + {
> +
> #ifdef FEAT_SCROLLBIND
> ! if (wp->w_p_scb)
> ! wp->w_p_scb = wp->w_p_scb_save;
> #endif
> #ifdef FEAT_CURSORBIND
> ! if (wp->w_p_crb)
> ! wp->w_p_crb = wp->w_p_crb_save;
> #endif
> ! if (!wp->w_p_wrap)
> ! wp->w_p_wrap = wp->w_p_wrap_save;
> #ifdef FEAT_FOLDING
> free_string_option(wp->w_p_fdm);
> ! wp->w_p_fdm = vim_strsave(wp->w_p_fdm_save);
> !
> ! if (wp->w_p_fdc == diff_foldcolumn)
> ! wp->w_p_fdc = wp->w_p_fdc_save;
> ! if (wp->w_p_fdl == 0)
> ! wp->w_p_fdl = wp->w_p_fdl_save;
>
> /* Only restore 'foldenable' when 'foldmethod' is not
> * "manual", otherwise we continue to show the diff folds. */
> ! if (wp->w_p_fen)
> ! wp->w_p_fen = foldmethodIsManual(wp) ? FALSE
> ! : wp->w_p_fen_save;
> !
> ! foldUpdateAll(wp);
> ! /* make sure topline is not halfway a fold */
> ! changed_window_setting_win(wp);
> ! #endif
> }
>
> /* Note: 'sbo' is not restored, it's a global option. */
> diff_buf_adjust(wp);
> }
> #ifdef FEAT_SCROLLBIND
> diffwin |= wp->w_p_diff;
> *** ../vim-7.4.767/src/version.c 2015-07-03 13:32:56.125020856 +0200
> --- src/version.c 2015-07-03 14:54:09.850320403 +0200
> ***************
> *** 743,744 ****
> --- 743,746 ----
> { /* Add new patch number below this line */
> + /**/
> + 768,
> /**/
>
> --
> If Apple would build a car...
> ... it would be powered by the sun, be reliable, five times
> as fast and twice as easy to drive; but would only run on
> five percent of the roads.
>
> /// 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.
--
Olaf Dabrunz (oda <at> fctrace.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.