aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2021-02-10 18:08:59 -0500
committerJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2021-02-10 18:20:02 -0500
commit81b4c881302640747de39f805312966c541acc47 (patch)
tree62c78074f611cb812eb630f6e1c88eeabeae06bd
parent81c9cda296666f049a23d11700e8f0deb6835d7d (diff)
downloadrneovim-81b4c881302640747de39f805312966c541acc47.tar.gz
rneovim-81b4c881302640747de39f805312966c541acc47.tar.bz2
rneovim-81b4c881302640747de39f805312966c541acc47.zip
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
-rw-r--r--runtime/doc/diff.txt4
-rw-r--r--runtime/doc/options.txt2
-rw-r--r--src/nvim/diff.c21
-rw-r--r--src/nvim/testdir/test_diffmode.vim15
4 files changed, 32 insertions, 10 deletions
diff --git a/runtime/doc/diff.txt b/runtime/doc/diff.txt
index 2a972483ff..3544882ceb 100644
--- a/runtime/doc/diff.txt
+++ b/runtime/doc/diff.txt
@@ -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
diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt
index 98e2d50f1d..ce3788e0fc 100644
--- a/runtime/doc/options.txt
+++ b/runtime/doc/options.txt
@@ -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
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;
diff --git a/src/nvim/testdir/test_diffmode.vim b/src/nvim/testdir/test_diffmode.vim
index f09a64c329..640de1bdc6 100644
--- a/src/nvim/testdir/test_diffmode.vim
+++ b/src/nvim/testdir/test_diffmode.vim
@@ -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