Greetings, While reading this article...
https://vimways.org/2018/the-power-of-diff/ ... yesterday, I discovered a subtle bug in the behavior when the 'diffopt' setting is changed. To observe, use the two attached files and run... vim --clean :e f2.rb :vsp f1.rb :windo diffthis Now, you can source the following two snippets of VimL: :set diffopt& :set diffopt+=algorithm:patience,indent-heuristic Observe the correct behavior after the above. :set diffopt& :set diffopt+=indent-heuristic,algorithm:patience Observe the incorrect behavior. This is because order matters in the "diffopt_changed()" function. I believe the patch, also attached, fixes this problem. It'd be great if Christian could take a look and verify my change. I didn't include a test because I thought I'd be more testing the output of the diff operation than the setting of the option. That is, there's no way to get direct access to the internal data managed by the option when set. Let me know if this is not acceptable. Best, Jason Franklin -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
f1.rb
Description: Binary data
f2.rb
Description: Binary data
diff --git a/src/diff.c b/src/diff.c
index 0399e7967..7f7e15df6 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -2173,6 +2173,7 @@ diffopt_changed(void)
int diff_flags_new = 0;
int diff_foldcolumn_new = 2;
long diff_algorithm_new = 0;
+ long diff_indent_heuristic = 0;
tabpage_T *tp;
p = p_dip;
@@ -2236,7 +2237,7 @@ diffopt_changed(void)
else if (STRNCMP(p, "indent-heuristic", 16) == 0)
{
p += 16;
- diff_algorithm_new |= XDF_INDENT_HEURISTIC;
+ diff_indent_heuristic = XDF_INDENT_HEURISTIC;
}
else if (STRNCMP(p, "internal", 8) == 0)
{
@@ -2276,6 +2277,8 @@ diffopt_changed(void)
++p;
}
+ diff_algorithm_new |= diff_indent_heuristic;
+
/* Can't have both "horizontal" and "vertical". */
if ((diff_flags_new & DIFF_HORIZONTAL) && (diff_flags_new & DIFF_VERTICAL))
return FAIL;
