On Di, 04 Dez 2018, Jason Franklin wrote:

> 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.

Thanks, the patch looks reasonable.

> 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.

How about the following (Note, I suppose the patience diff alogrithm 
does not actually change the diff produced, so enhancing the existings 
tests and using the existing dumps should work):

diff --git a/src/testdir/test_diffmode.vim b/src/testdir/test_diffmode.vim
index 4f20395ab..7681b5ce1 100644
--- a/src/testdir/test_diffmode.vim
+++ b/src/testdir/test_diffmode.vim
@@ -815,6 +815,13 @@ func Test_diff_screen()

   call term_sendkeys(buf, ":set diffopt+=indent-heuristic\<cr>")
   call VerifyScreenDump(buf, 'Test_diff_11', {})
+  " shouldn't matter, if indent-algorithm comes before or after the algorithm
+  call term_sendkeys(buf, ":set diffopt&\<cr>")
+  call term_sendkeys(buf, ":set 
diffopt+=indent-heuristic,algorithm:patience\<cr>")
+  call VerifyScreenDump(buf, 'Test_diff_11', {})
+  call term_sendkeys(buf, ":set diffopt&\<cr>")
+  call term_sendkeys(buf, ":set 
diffopt+=algorithm:patience,indent-heuristic\<cr>")
+  call VerifyScreenDump(buf, 'Test_diff_11', {})

   " Test 12: diff the same file
   call WriteDiffFiles(buf, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 
7, 8, 9, 10])






Best,
Christian
-- 
UNIX-Airlines
Jedermann bringt ein Stück des Flugzeuges zum Flughafen mit. Alle
gehen auf die Startbahn und setzen das Flugzeug Stück für Stück
zusammen.  Dabei diskutieren sie fortwährend, welche Art von Flugzeug
sie gerade zusammenbauen.

-- 
-- 
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 vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui