To: vim_dev@googlegroups.com Subject: Patch 8.2.2490 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.2490 Problem: 'wrap' option is always reset when starting diff mode. Solution: Add the "followwrap" item in 'diffopt'. (Rick Howe, closes #7797) Files: runtime/doc/diff.txt, runtime/doc/options.txt, src/diff.c, src/testdir/test_diffmode.vim *** ../vim-8.2.2489/runtime/doc/diff.txt 2019-12-12 12:49:05.000000000 +0100 --- runtime/doc/diff.txt 2021-02-10 13:13:54.084509120 +0100 *************** *** 59,65 **** 'scrollbind' on 'cursorbind' on 'scrollopt' includes "hor" ! 'wrap' off 'foldmethod' "diff" 'foldcolumn' value from 'diffopt', default is 2 --- 59,65 ---- 'scrollbind' on 'cursorbind' on 'scrollopt' includes "hor" ! 'wrap' off, or leave as-is if 'diffopt' includes "followwrap" 'foldmethod' "diff" 'foldcolumn' value from 'diffopt', default is 2 *************** *** 144,150 **** 'scrollbind' off 'cursorbind' off 'scrollopt' without "hor" ! 'wrap' on 'foldmethod' "manual" 'foldcolumn' 0 --- 144,150 ---- 'scrollbind' off 'cursorbind' off 'scrollopt' without "hor" ! 'wrap' on, or leave as-is if 'diffopt' includes "followwrap" 'foldmethod' "manual" 'foldcolumn' 0 *** ../vim-8.2.2489/runtime/doc/options.txt 2021-02-03 15:58:09.084690899 +0100 --- runtime/doc/options.txt 2021-02-10 13:13:54.084509120 +0100 *************** *** 2677,2682 **** --- 2677,2684 ---- 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 *** ../vim-8.2.2489/src/diff.c 2020-10-24 20:49:37.490683063 +0200 --- src/diff.c 2021-02-10 13:13:54.084509120 +0100 *************** *** 36,41 **** --- 36,42 ---- #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,1462 **** 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; # ifdef FEAT_FOLDING if (!wp->w_p_diff) { --- 1455,1466 ---- if (!wp->w_p_diff) wp->w_p_crb_save = wp->w_p_crb; wp->w_p_crb = TRUE; ! 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,1524 **** 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; #ifdef FEAT_FOLDING free_string_option(wp->w_p_fdm); wp->w_p_fdm = vim_strsave( --- 1521,1531 ---- wp->w_p_scb = wp->w_p_scb_save; if (wp->w_p_crb) wp->w_p_crb = wp->w_p_crb_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,2250 **** --- 2252,2262 ---- 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; *** ../vim-8.2.2489/src/testdir/test_diffmode.vim 2020-11-27 19:13:24.186184976 +0100 --- src/testdir/test_diffmode.vim 2021-02-10 13:13:54.084509120 +0100 *************** *** 1045,1050 **** --- 1045,1065 ---- 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_maintains_change_mark() enew! call setline(1, ['a', 'b', 'c', 'd']) *** ../vim-8.2.2489/src/version.c 2021-02-09 20:02:52.618109261 +0100 --- src/version.c 2021-02-10 13:14:45.956352199 +0100 *************** *** 752,753 **** --- 752,755 ---- { /* Add new patch number below this line */ + /**/ + 2490, /**/ -- ARTHUR: Well, I AM king... DENNIS: Oh king, eh, very nice. An' how'd you get that, eh? By exploitin' the workers -- by 'angin' on to outdated imperialist dogma which perpetuates the economic an' social differences in our society! If there's ever going to be any progress-- The Quest for the Holy Grail (Monty Python) /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///