From 81b4c881302640747de39f805312966c541acc47 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Wed, 10 Feb 2021 18:08:59 -0500 Subject: 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) https://github.com/vim/vim/commit/4223d43c0fb6ead1e611e4469a1680a9228b6015 --- src/nvim/diff.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'src/nvim/diff.c') diff --git a/src/nvim/diff.c b/src/nvim/diff.c index 358725239c..31b7b1bd8f 100644 --- a/src/nvim/diff.c +++ b/src/nvim/diff.c @@ -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; -- cgit