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

updated for version 7.3.1294

Problem:    ":diffoff" resets options.
Solution:   Save and restore option values. (Christian Brabandt)
This commit is contained in:
Bram Moolenaar 2013-07-03 15:47:03 +02:00
parent caf2dffd51
commit a87aa8061c
4 changed files with 80 additions and 7 deletions

View File

@ -1138,21 +1138,36 @@ diff_win_options(wp, addbuf)
# endif # endif
wp->w_p_diff = TRUE; 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)
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)
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)
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)
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)
{
wp->w_p_fdc_save = wp->w_p_fdc;
wp->w_p_fen_save = wp->w_p_fen;
wp->w_p_fdl_save = wp->w_p_fdl;
}
wp->w_p_fdc = diff_foldcolumn; wp->w_p_fdc = diff_foldcolumn;
wp->w_p_fen = TRUE; wp->w_p_fen = TRUE;
wp->w_p_fdl = 0; wp->w_p_fdl = 0;
@ -1164,6 +1179,8 @@ diff_win_options(wp, addbuf)
if (vim_strchr(p_sbo, 'h') == NULL) if (vim_strchr(p_sbo, 'h') == NULL)
do_cmdline_cmd((char_u *)"set sbo+=hor"); do_cmdline_cmd((char_u *)"set sbo+=hor");
#endif #endif
/* Saved the current values, to be restored in ex_diffoff(). */
wp->w_p_diff_saved = TRUE;
if (addbuf) if (addbuf)
diff_buf_add(wp->w_buffer); diff_buf_add(wp->w_buffer);
@ -1188,25 +1205,48 @@ ex_diffoff(eap)
{ {
if (wp == curwin || (eap->forceit && wp->w_p_diff)) if (wp == curwin || (eap->forceit && wp->w_p_diff))
{ {
/* Set 'diff', 'scrollbind' off and 'wrap' on. */ /* Set 'diff', 'scrollbind' off and 'wrap' on. If option values
* were saved in diff_win_options() restore them. */
wp->w_p_diff = FALSE; wp->w_p_diff = FALSE;
RESET_BINDING(wp);
wp->w_p_wrap = TRUE; #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 #ifdef FEAT_FOLDING
curwin = wp; curwin = wp;
curbuf = curwin->w_buffer; curbuf = curwin->w_buffer;
set_string_option_direct((char_u *)"fdm", -1, 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); (char_u *)"manual", OPT_LOCAL|OPT_FREE, 0);
curwin = old_curwin; curwin = old_curwin;
curbuf = curwin->w_buffer; curbuf = curwin->w_buffer;
wp->w_p_fdc = 0; if (wp->w_p_fdc == diff_foldcolumn)
wp->w_p_fen = FALSE; wp->w_p_fdc = wp->w_p_diff_saved ? wp->w_p_fdc_save : 0;
wp->w_p_fdl = 0; if (wp->w_p_fen)
wp->w_p_fen = wp->w_p_diff_saved ? wp->w_p_fen_save : FALSE;
if (wp->w_p_fdl == 0 && wp->w_p_diff_saved)
wp->w_p_fdl = wp->w_p_fdl_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. */
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

@ -10118,14 +10118,19 @@ copy_winopt(from, to)
to->wo_stl = vim_strsave(from->wo_stl); to->wo_stl = vim_strsave(from->wo_stl);
#endif #endif
to->wo_wrap = from->wo_wrap; to->wo_wrap = from->wo_wrap;
#ifdef FEAT_DIFF
to->wo_wrap_save = from->wo_wrap_save;
#endif
#ifdef FEAT_LINEBREAK #ifdef FEAT_LINEBREAK
to->wo_lbr = from->wo_lbr; to->wo_lbr = from->wo_lbr;
#endif #endif
#ifdef FEAT_SCROLLBIND #ifdef FEAT_SCROLLBIND
to->wo_scb = from->wo_scb; to->wo_scb = from->wo_scb;
to->wo_scb_save = from->wo_scb_save;
#endif #endif
#ifdef FEAT_CURSORBIND #ifdef FEAT_CURSORBIND
to->wo_crb = from->wo_crb; to->wo_crb = from->wo_crb;
to->wo_crb_save = from->wo_crb_save;
#endif #endif
#ifdef FEAT_SPELL #ifdef FEAT_SPELL
to->wo_spell = from->wo_spell; to->wo_spell = from->wo_spell;
@ -10137,6 +10142,7 @@ copy_winopt(from, to)
#endif #endif
#ifdef FEAT_DIFF #ifdef FEAT_DIFF
to->wo_diff = from->wo_diff; to->wo_diff = from->wo_diff;
to->wo_diff_saved = from->wo_diff_saved;
#endif #endif
#ifdef FEAT_CONCEAL #ifdef FEAT_CONCEAL
to->wo_cocu = vim_strsave(from->wo_cocu); to->wo_cocu = vim_strsave(from->wo_cocu);
@ -10144,11 +10150,16 @@ copy_winopt(from, to)
#endif #endif
#ifdef FEAT_FOLDING #ifdef FEAT_FOLDING
to->wo_fdc = from->wo_fdc; to->wo_fdc = from->wo_fdc;
to->wo_fdc_save = from->wo_fdc_save;
to->wo_fen = from->wo_fen; to->wo_fen = from->wo_fen;
to->wo_fen_save = from->wo_fen_save;
to->wo_fdi = vim_strsave(from->wo_fdi); to->wo_fdi = vim_strsave(from->wo_fdi);
to->wo_fml = from->wo_fml; to->wo_fml = from->wo_fml;
to->wo_fdl = from->wo_fdl; to->wo_fdl = from->wo_fdl;
to->wo_fdl_save = from->wo_fdl_save;
to->wo_fdm = vim_strsave(from->wo_fdm); to->wo_fdm = vim_strsave(from->wo_fdm);
to->wo_fdm_save = from->wo_diff_saved
? vim_strsave(from->wo_fdm_save) : empty_option;
to->wo_fdn = from->wo_fdn; to->wo_fdn = from->wo_fdn;
# ifdef FEAT_EVAL # ifdef FEAT_EVAL
to->wo_fde = vim_strsave(from->wo_fde); to->wo_fde = vim_strsave(from->wo_fde);
@ -10180,6 +10191,7 @@ check_winopt(wop)
#ifdef FEAT_FOLDING #ifdef FEAT_FOLDING
check_string_option(&wop->wo_fdi); check_string_option(&wop->wo_fdi);
check_string_option(&wop->wo_fdm); check_string_option(&wop->wo_fdm);
check_string_option(&wop->wo_fdm_save);
# ifdef FEAT_EVAL # ifdef FEAT_EVAL
check_string_option(&wop->wo_fde); check_string_option(&wop->wo_fde);
check_string_option(&wop->wo_fdt); check_string_option(&wop->wo_fdt);
@ -10210,6 +10222,7 @@ clear_winopt(wop)
#ifdef FEAT_FOLDING #ifdef FEAT_FOLDING
clear_string_option(&wop->wo_fdi); clear_string_option(&wop->wo_fdi);
clear_string_option(&wop->wo_fdm); clear_string_option(&wop->wo_fdm);
clear_string_option(&wop->wo_fdm_save);
# ifdef FEAT_EVAL # ifdef FEAT_EVAL
clear_string_option(&wop->wo_fde); clear_string_option(&wop->wo_fde);
clear_string_option(&wop->wo_fdt); clear_string_option(&wop->wo_fdt);

View File

@ -141,14 +141,22 @@ typedef struct
#ifdef FEAT_FOLDING #ifdef FEAT_FOLDING
long wo_fdc; long wo_fdc;
# define w_p_fdc w_onebuf_opt.wo_fdc /* 'foldcolumn' */ # define w_p_fdc w_onebuf_opt.wo_fdc /* 'foldcolumn' */
int wo_fdc_save;
# define w_p_fdc_save w_onebuf_opt.wo_fdc_save /* 'foldenable' saved for diff mode */
int wo_fen; int wo_fen;
# define w_p_fen w_onebuf_opt.wo_fen /* 'foldenable' */ # define w_p_fen w_onebuf_opt.wo_fen /* 'foldenable' */
int wo_fen_save;
# define w_p_fen_save w_onebuf_opt.wo_fen_save /* 'foldenable' saved for diff mode */
char_u *wo_fdi; char_u *wo_fdi;
# define w_p_fdi w_onebuf_opt.wo_fdi /* 'foldignore' */ # define w_p_fdi w_onebuf_opt.wo_fdi /* 'foldignore' */
long wo_fdl; long wo_fdl;
# define w_p_fdl w_onebuf_opt.wo_fdl /* 'foldlevel' */ # define w_p_fdl w_onebuf_opt.wo_fdl /* 'foldlevel' */
int wo_fdl_save;
# define w_p_fdl_save w_onebuf_opt.wo_fdl_save /* 'foldlevel' state saved for diff mode */
char_u *wo_fdm; char_u *wo_fdm;
# define w_p_fdm w_onebuf_opt.wo_fdm /* 'foldmethod' */ # define w_p_fdm w_onebuf_opt.wo_fdm /* 'foldmethod' */
char_u *wo_fdm_save;
# define w_p_fdm_save w_onebuf_opt.wo_fdm_save /* 'fdm' saved for diff mode */
long wo_fml; long wo_fml;
# define w_p_fml w_onebuf_opt.wo_fml /* 'foldminlines' */ # define w_p_fml w_onebuf_opt.wo_fml /* 'foldminlines' */
long wo_fdn; long wo_fdn;
@ -213,9 +221,17 @@ typedef struct
#ifdef FEAT_SCROLLBIND #ifdef FEAT_SCROLLBIND
int wo_scb; int wo_scb;
# define w_p_scb w_onebuf_opt.wo_scb /* 'scrollbind' */ # define w_p_scb w_onebuf_opt.wo_scb /* 'scrollbind' */
int wo_diff_saved; /* options were saved for starting diff mode */
# define w_p_diff_saved w_onebuf_opt.wo_diff_saved
int wo_scb_save; /* 'scrollbind' saved for diff mode*/
# define w_p_scb_save w_onebuf_opt.wo_scb_save
#endif #endif
int wo_wrap; int wo_wrap;
#define w_p_wrap w_onebuf_opt.wo_wrap /* 'wrap' */ #define w_p_wrap w_onebuf_opt.wo_wrap /* 'wrap' */
#ifdef FEAT_DIFF
int wo_wrap_save; /* 'wrap' state saved for diff mode*/
# define w_p_wrap_save w_onebuf_opt.wo_wrap_save
#endif
#ifdef FEAT_CONCEAL #ifdef FEAT_CONCEAL
char_u *wo_cocu; /* 'concealcursor' */ char_u *wo_cocu; /* 'concealcursor' */
# define w_p_cocu w_onebuf_opt.wo_cocu # define w_p_cocu w_onebuf_opt.wo_cocu
@ -225,6 +241,8 @@ typedef struct
#ifdef FEAT_CURSORBIND #ifdef FEAT_CURSORBIND
int wo_crb; int wo_crb;
# define w_p_crb w_onebuf_opt.wo_crb /* 'cursorbind' */ # define w_p_crb w_onebuf_opt.wo_crb /* 'cursorbind' */
int wo_crb_save; /* 'cursorbind' state saved for diff mode*/
# define w_p_crb_save w_onebuf_opt.wo_crb_save
#endif #endif
#ifdef FEAT_EVAL #ifdef FEAT_EVAL

View File

@ -728,6 +728,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 */
/**/
1294,
/**/ /**/
1293, 1293,
/**/ /**/