0
0
mirror of https://github.com/vim/vim.git synced 2025-09-26 04:04:07 -04:00

patch 7.4.768

Problem:    :diffoff only works properly once.
Solution:   Also make :diffoff work when used a second time. (Olaf Dabrunz)
This commit is contained in:
Bram Moolenaar
2015-07-03 15:06:56 +02:00
parent fafeee6b9e
commit 4392996461
2 changed files with 43 additions and 48 deletions

View File

@@ -1138,32 +1138,34 @@ diff_win_options(wp, addbuf)
curwin = old_curwin; curwin = old_curwin;
# endif # endif
wp->w_p_diff = TRUE;
/* Use 'scrollbind' and 'cursorbind' when available */ /* Use 'scrollbind' and 'cursorbind' when available */
#ifdef FEAT_SCROLLBIND #ifdef FEAT_SCROLLBIND
if (!wp->w_p_diff_saved) if (!wp->w_p_diff)
wp->w_p_scb_save = wp->w_p_scb; wp->w_p_scb_save = wp->w_p_scb;
wp->w_p_scb = TRUE; wp->w_p_scb = TRUE;
#endif #endif
#ifdef FEAT_CURSORBIND #ifdef FEAT_CURSORBIND
if (!wp->w_p_diff_saved) if (!wp->w_p_diff)
wp->w_p_crb_save = wp->w_p_crb; wp->w_p_crb_save = wp->w_p_crb;
wp->w_p_crb = TRUE; wp->w_p_crb = TRUE;
#endif #endif
if (!wp->w_p_diff_saved) if (!wp->w_p_diff)
wp->w_p_wrap_save = wp->w_p_wrap; wp->w_p_wrap_save = wp->w_p_wrap;
wp->w_p_wrap = FALSE; wp->w_p_wrap = FALSE;
# ifdef FEAT_FOLDING # ifdef FEAT_FOLDING
curwin = wp; curwin = wp;
curbuf = curwin->w_buffer; curbuf = curwin->w_buffer;
if (!wp->w_p_diff_saved) 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); wp->w_p_fdm_save = vim_strsave(wp->w_p_fdm);
}
set_string_option_direct((char_u *)"fdm", -1, (char_u *)"diff", set_string_option_direct((char_u *)"fdm", -1, (char_u *)"diff",
OPT_LOCAL|OPT_FREE, 0); OPT_LOCAL|OPT_FREE, 0);
curwin = old_curwin; curwin = old_curwin;
curbuf = curwin->w_buffer; curbuf = curwin->w_buffer;
if (!wp->w_p_diff_saved) if (!wp->w_p_diff)
{ {
wp->w_p_fdc_save = wp->w_p_fdc; wp->w_p_fdc_save = wp->w_p_fdc;
wp->w_p_fen_save = wp->w_p_fen; wp->w_p_fen_save = wp->w_p_fen;
@@ -1183,6 +1185,8 @@ diff_win_options(wp, addbuf)
/* Saved the current values, to be restored in ex_diffoff(). */ /* Saved the current values, to be restored in ex_diffoff(). */
wp->w_p_diff_saved = TRUE; wp->w_p_diff_saved = TRUE;
wp->w_p_diff = TRUE;
if (addbuf) if (addbuf)
diff_buf_add(wp->w_buffer); diff_buf_add(wp->w_buffer);
redraw_win_later(wp, NOT_VALID); redraw_win_later(wp, NOT_VALID);
@@ -1197,7 +1201,6 @@ ex_diffoff(eap)
exarg_T *eap; exarg_T *eap;
{ {
win_T *wp; win_T *wp;
win_T *old_curwin = curwin;
#ifdef FEAT_SCROLLBIND #ifdef FEAT_SCROLLBIND
int diffwin = FALSE; int diffwin = FALSE;
#endif #endif
@@ -1206,57 +1209,47 @@ ex_diffoff(eap)
{ {
if (eap->forceit ? wp->w_p_diff : wp == curwin) if (eap->forceit ? wp->w_p_diff : wp == curwin)
{ {
/* Set 'diff', 'scrollbind' off and 'wrap' on. If option values /* Set 'diff' off. If option values were saved in
* were saved in diff_win_options() restore them. */ * diff_win_options(), restore the ones whose settings seem to have
* been left over from diff mode. */
wp->w_p_diff = FALSE; wp->w_p_diff = FALSE;
if (wp->w_p_diff_saved)
{
#ifdef FEAT_SCROLLBIND #ifdef FEAT_SCROLLBIND
if (wp->w_p_scb) if (wp->w_p_scb)
wp->w_p_scb = wp->w_p_diff_saved ? wp->w_p_scb_save : FALSE; wp->w_p_scb = wp->w_p_scb_save;
#endif #endif
#ifdef FEAT_CURSORBIND #ifdef FEAT_CURSORBIND
if (wp->w_p_crb) if (wp->w_p_crb)
wp->w_p_crb = wp->w_p_diff_saved ? wp->w_p_crb_save : FALSE; wp->w_p_crb = wp->w_p_crb_save;
#endif #endif
if (!wp->w_p_wrap) if (!wp->w_p_wrap)
wp->w_p_wrap = wp->w_p_diff_saved ? wp->w_p_wrap_save : TRUE; wp->w_p_wrap = wp->w_p_wrap_save;
#ifdef FEAT_FOLDING #ifdef FEAT_FOLDING
curwin = wp;
curbuf = curwin->w_buffer;
if (wp->w_p_diff_saved)
{
free_string_option(wp->w_p_fdm); free_string_option(wp->w_p_fdm);
wp->w_p_fdm = wp->w_p_fdm_save; wp->w_p_fdm = vim_strsave(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) if (wp->w_p_fdc == diff_foldcolumn)
wp->w_p_fdc = wp->w_p_diff_saved ? wp->w_p_fdc_save : 0; wp->w_p_fdc = wp->w_p_fdc_save;
if (wp->w_p_fdl == 0 && wp->w_p_diff_saved) if (wp->w_p_fdl == 0)
wp->w_p_fdl = wp->w_p_fdl_save; wp->w_p_fdl = wp->w_p_fdl_save;
if (wp->w_p_fen)
{
/* Only restore 'foldenable' when 'foldmethod' is not /* Only restore 'foldenable' when 'foldmethod' is not
* "manual", otherwise we continue to show the diff folds. */ * "manual", otherwise we continue to show the diff folds. */
if (foldmethodIsManual(wp) || !wp->w_p_diff_saved) if (wp->w_p_fen)
wp->w_p_fen = FALSE; wp->w_p_fen = foldmethodIsManual(wp) ? FALSE
else : wp->w_p_fen_save;
wp->w_p_fen = wp->w_p_fen_save;
}
foldUpdateAll(wp); foldUpdateAll(wp);
/* make sure topline is not halfway a fold */ /* make sure topline is not halfway a fold */
changed_window_setting_win(wp); changed_window_setting_win(wp);
#endif #endif
}
/* Note: 'sbo' is not restored, it's a global option. */ /* Note: 'sbo' is not restored, it's a global option. */
diff_buf_adjust(wp); diff_buf_adjust(wp);
wp->w_p_diff_saved = FALSE;
} }
#ifdef FEAT_SCROLLBIND #ifdef FEAT_SCROLLBIND
diffwin |= wp->w_p_diff; diffwin |= wp->w_p_diff;

View File

@@ -741,6 +741,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
768,
/**/ /**/
767, 767,
/**/ /**/