mirror of
https://github.com/vim/vim.git
synced 2025-09-25 03:54:15 -04:00
patch 8.2.2490: 'wrap' option is always reset when starting diff mode
Problem: 'wrap' option is always reset when starting diff mode. Solution: Add the "followwrap" item in 'diffopt'. (Rick Howe, closes #7797)
This commit is contained in:
@@ -59,7 +59,7 @@ In each of the edited files these options are set:
|
|||||||
'scrollbind' on
|
'scrollbind' on
|
||||||
'cursorbind' on
|
'cursorbind' on
|
||||||
'scrollopt' includes "hor"
|
'scrollopt' includes "hor"
|
||||||
'wrap' off
|
'wrap' off, or leave as-is if 'diffopt' includes "followwrap"
|
||||||
'foldmethod' "diff"
|
'foldmethod' "diff"
|
||||||
'foldcolumn' value from 'diffopt', default is 2
|
'foldcolumn' value from 'diffopt', default is 2
|
||||||
|
|
||||||
@@ -144,7 +144,7 @@ Otherwise they are set to their default value:
|
|||||||
'scrollbind' off
|
'scrollbind' off
|
||||||
'cursorbind' off
|
'cursorbind' off
|
||||||
'scrollopt' without "hor"
|
'scrollopt' without "hor"
|
||||||
'wrap' on
|
'wrap' on, or leave as-is if 'diffopt' includes "followwrap"
|
||||||
'foldmethod' "manual"
|
'foldmethod' "manual"
|
||||||
'foldcolumn' 0
|
'foldcolumn' 0
|
||||||
|
|
||||||
|
@@ -2677,6 +2677,8 @@ A jump table for the options with a short description can be found at |Q_op|.
|
|||||||
foldcolumn:{n} Set the 'foldcolumn' option to {n} when
|
foldcolumn:{n} Set the 'foldcolumn' option to {n} when
|
||||||
starting diff mode. Without this 2 is used.
|
starting diff mode. Without this 2 is used.
|
||||||
|
|
||||||
|
followwrap Follow the 'wrap' option and leave as it is.
|
||||||
|
|
||||||
internal Use the internal diff library. This is
|
internal Use the internal diff library. This is
|
||||||
ignored when 'diffexpr' is set. *E960*
|
ignored when 'diffexpr' is set. *E960*
|
||||||
When running out of memory when writing a
|
When running out of memory when writing a
|
||||||
|
22
src/diff.c
22
src/diff.c
@@ -36,6 +36,7 @@ static int diff_need_update = FALSE; // ex_diffupdate needs to be called
|
|||||||
#define DIFF_HIDDEN_OFF 0x100 // diffoff when hidden
|
#define DIFF_HIDDEN_OFF 0x100 // diffoff when hidden
|
||||||
#define DIFF_INTERNAL 0x200 // use internal xdiff algorithm
|
#define DIFF_INTERNAL 0x200 // use internal xdiff algorithm
|
||||||
#define DIFF_CLOSE_OFF 0x400 // diffoff when closing window
|
#define DIFF_CLOSE_OFF 0x400 // diffoff when closing window
|
||||||
|
#define DIFF_FOLLOWWRAP 0x800 // follow the wrap option
|
||||||
#define ALL_WHITE_DIFF (DIFF_IWHITE | DIFF_IWHITEALL | DIFF_IWHITEEOL)
|
#define ALL_WHITE_DIFF (DIFF_IWHITE | DIFF_IWHITEALL | DIFF_IWHITEEOL)
|
||||||
static int diff_flags = DIFF_INTERNAL | DIFF_FILLER | DIFF_CLOSE_OFF;
|
static int diff_flags = DIFF_INTERNAL | DIFF_FILLER | DIFF_CLOSE_OFF;
|
||||||
|
|
||||||
@@ -1454,9 +1455,12 @@ diff_win_options(
|
|||||||
if (!wp->w_p_diff)
|
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;
|
||||||
if (!wp->w_p_diff)
|
if (!(diff_flags & DIFF_FOLLOWWRAP))
|
||||||
wp->w_p_wrap_save = wp->w_p_wrap;
|
{
|
||||||
wp->w_p_wrap = FALSE;
|
if (!wp->w_p_diff)
|
||||||
|
wp->w_p_wrap_save = wp->w_p_wrap;
|
||||||
|
wp->w_p_wrap = FALSE;
|
||||||
|
}
|
||||||
# ifdef FEAT_FOLDING
|
# ifdef FEAT_FOLDING
|
||||||
if (!wp->w_p_diff)
|
if (!wp->w_p_diff)
|
||||||
{
|
{
|
||||||
@@ -1517,8 +1521,11 @@ ex_diffoff(exarg_T *eap)
|
|||||||
wp->w_p_scb = wp->w_p_scb_save;
|
wp->w_p_scb = wp->w_p_scb_save;
|
||||||
if (wp->w_p_crb)
|
if (wp->w_p_crb)
|
||||||
wp->w_p_crb = wp->w_p_crb_save;
|
wp->w_p_crb = wp->w_p_crb_save;
|
||||||
if (!wp->w_p_wrap)
|
if (!(diff_flags & DIFF_FOLLOWWRAP))
|
||||||
wp->w_p_wrap = wp->w_p_wrap_save;
|
{
|
||||||
|
if (!wp->w_p_wrap)
|
||||||
|
wp->w_p_wrap = wp->w_p_wrap_save;
|
||||||
|
}
|
||||||
#ifdef FEAT_FOLDING
|
#ifdef FEAT_FOLDING
|
||||||
free_string_option(wp->w_p_fdm);
|
free_string_option(wp->w_p_fdm);
|
||||||
wp->w_p_fdm = vim_strsave(
|
wp->w_p_fdm = vim_strsave(
|
||||||
@@ -2245,6 +2252,11 @@ diffopt_changed(void)
|
|||||||
p += 8;
|
p += 8;
|
||||||
diff_flags_new |= DIFF_CLOSE_OFF;
|
diff_flags_new |= DIFF_CLOSE_OFF;
|
||||||
}
|
}
|
||||||
|
else if (STRNCMP(p, "followwrap", 10) == 0)
|
||||||
|
{
|
||||||
|
p += 10;
|
||||||
|
diff_flags_new |= DIFF_FOLLOWWRAP;
|
||||||
|
}
|
||||||
else if (STRNCMP(p, "indent-heuristic", 16) == 0)
|
else if (STRNCMP(p, "indent-heuristic", 16) == 0)
|
||||||
{
|
{
|
||||||
p += 16;
|
p += 16;
|
||||||
|
@@ -1045,6 +1045,21 @@ func Test_diff_closeoff()
|
|||||||
enew!
|
enew!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_diff_followwrap()
|
||||||
|
new
|
||||||
|
set diffopt+=followwrap
|
||||||
|
set wrap
|
||||||
|
diffthis
|
||||||
|
call assert_equal(1, &wrap)
|
||||||
|
diffoff
|
||||||
|
set nowrap
|
||||||
|
diffthis
|
||||||
|
call assert_equal(0, &wrap)
|
||||||
|
diffoff
|
||||||
|
set diffopt&
|
||||||
|
bwipe!
|
||||||
|
endfunc
|
||||||
|
|
||||||
func Test_diff_maintains_change_mark()
|
func Test_diff_maintains_change_mark()
|
||||||
enew!
|
enew!
|
||||||
call setline(1, ['a', 'b', 'c', 'd'])
|
call setline(1, ['a', 'b', 'c', 'd'])
|
||||||
|
@@ -750,6 +750,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 */
|
||||||
|
/**/
|
||||||
|
2490,
|
||||||
/**/
|
/**/
|
||||||
2489,
|
2489,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user