mirror of
https://github.com/neovim/neovim.git
synced 2024-12-20 11:15:14 -07:00
vim-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 vim/vim#7797)
4223d43c0f
This commit is contained in:
parent
81c9cda296
commit
81b4c88130
@ -48,7 +48,7 @@ In each of the edited files these options are set:
|
||||
'scrollbind' on
|
||||
'cursorbind' on
|
||||
'scrollopt' includes "hor"
|
||||
'wrap' off
|
||||
'wrap' off, or leave as-is if 'diffopt' includes "followwrap"
|
||||
'foldmethod' "diff"
|
||||
'foldcolumn' value from 'diffopt', default is 2
|
||||
|
||||
@ -132,7 +132,7 @@ Otherwise they are set to their default value:
|
||||
'scrollbind' off
|
||||
'cursorbind' off
|
||||
'scrollopt' without "hor"
|
||||
'wrap' on
|
||||
'wrap' on, or leave as-is if 'diffopt' includes "followwrap"
|
||||
'foldmethod' "manual"
|
||||
'foldcolumn' 0
|
||||
|
||||
|
@ -1971,6 +1971,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
|
||||
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
|
||||
ignored when 'diffexpr' is set. *E960*
|
||||
When running out of memory when writing a
|
||||
|
@ -58,6 +58,7 @@ static bool diff_need_update = false; // ex_diffupdate needs to be called
|
||||
#define DIFF_HIDDEN_OFF 0x100 // diffoff when hidden
|
||||
#define DIFF_INTERNAL 0x200 // use internal xdiff algorithm
|
||||
#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)
|
||||
static int diff_flags = DIFF_INTERNAL | DIFF_FILLER | DIFF_CLOSE_OFF;
|
||||
|
||||
@ -1361,11 +1362,12 @@ void diff_win_options(win_T *wp, int addbuf)
|
||||
wp->w_p_crb_save = wp->w_p_crb;
|
||||
}
|
||||
wp->w_p_crb = true;
|
||||
|
||||
if (!wp->w_p_diff) {
|
||||
wp->w_p_wrap_save = wp->w_p_wrap;
|
||||
if (!(diff_flags & DIFF_FOLLOWWRAP)) {
|
||||
if (!wp->w_p_diff) {
|
||||
wp->w_p_wrap_save = wp->w_p_wrap;
|
||||
}
|
||||
wp->w_p_wrap = false;
|
||||
}
|
||||
wp->w_p_wrap = false;
|
||||
curwin = wp; // -V519
|
||||
curbuf = curwin->w_buffer;
|
||||
|
||||
@ -1437,11 +1439,11 @@ void ex_diffoff(exarg_T *eap)
|
||||
if (wp->w_p_crb) {
|
||||
wp->w_p_crb = wp->w_p_crb_save;
|
||||
}
|
||||
|
||||
if (!wp->w_p_wrap) {
|
||||
wp->w_p_wrap = wp->w_p_wrap_save;
|
||||
if (!(diff_flags & DIFF_FOLLOWWRAP)) {
|
||||
if (!wp->w_p_wrap) {
|
||||
wp->w_p_wrap = wp->w_p_wrap_save;
|
||||
}
|
||||
}
|
||||
|
||||
free_string_option(wp->w_p_fdm);
|
||||
wp->w_p_fdm = vim_strsave(*wp->w_p_fdm_save
|
||||
? wp->w_p_fdm_save
|
||||
@ -2158,6 +2160,9 @@ int diffopt_changed(void)
|
||||
} else if (STRNCMP(p, "closeoff", 8) == 0) {
|
||||
p += 8;
|
||||
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) {
|
||||
p += 16;
|
||||
diff_indent_heuristic = XDF_INDENT_HEURISTIC;
|
||||
|
@ -964,6 +964,21 @@ func Test_diff_closeoff()
|
||||
enew!
|
||||
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_rnu()
|
||||
CheckScreendump
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user