Mercurial > vim
diff src/diff.c @ 23895:e313b6ee2d9c v8.2.2490
patch 8.2.2490: 'wrap' option is always reset when starting diff mode
Commit: https://github.com/vim/vim/commit/4223d43c0fb6ead1e611e4469a1680a9228b6015
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Feb 10 13:18:17 2021 +0100
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 https://github.com/vim/vim/issues/7797)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 10 Feb 2021 13:30:03 +0100 |
parents | e82579016863 |
children | 05c199ea8295 |
line wrap: on
line diff
--- a/src/diff.c +++ b/src/diff.c @@ -36,6 +36,7 @@ static int diff_need_update = FALSE; // #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; @@ -1454,9 +1455,12 @@ diff_win_options( if (!wp->w_p_diff) 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; - wp->w_p_wrap = FALSE; + if (!(diff_flags & DIFF_FOLLOWWRAP)) + { + if (!wp->w_p_diff) + wp->w_p_wrap_save = wp->w_p_wrap; + wp->w_p_wrap = FALSE; + } # ifdef FEAT_FOLDING if (!wp->w_p_diff) { @@ -1517,8 +1521,11 @@ ex_diffoff(exarg_T *eap) wp->w_p_scb = wp->w_p_scb_save; 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; + } #ifdef FEAT_FOLDING free_string_option(wp->w_p_fdm); wp->w_p_fdm = vim_strsave( @@ -2245,6 +2252,11 @@ diffopt_changed(void) 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;