mbox series

[v4,0/7] mergetools: vimdiff: regression fixes and improvements

Message ID 20220810154618.307275-1-felipe.contreras@gmail.com (mailing list archive)
Headers show
Series mergetools: vimdiff: regression fixes and improvements | expand

Message

Felipe Contreras Aug. 10, 2022, 3:46 p.m. UTC
Hello,

These patches make vimdiff3 actually work, along with many single window
cases.

Since 3 the patches have been reorganized to do the tab reoganization
first, and then the rest become simple. I also dropped one intermediate
patch which isn't necessary.

Felipe Contreras (7):
  mergetools: vimdiff: fix comment
  mergetools: vimdiff: make vimdiff3 actually work
  mergetools: vimdiff: silence annoying messages
  mergetools: vimdiff: fix for diffopt
  mergetools: vimdiff: rework tab logic
  mergetools: vimdiff: fix single window layouts
  mergetools: vimdiff: simplify tabfirst

 mergetools/vimdiff | 102 +++++++++++++++++++--------------------------
 1 file changed, 43 insertions(+), 59 deletions(-)

Range-diff against v3:
1:  20c5abdbc8 = 1:  20c5abdbc8 mergetools: vimdiff: fix comment
2:  8d466e06aa ! 2:  f0bf1bc1c2 mergetools: vimdiff: make vimdiff3 actually work
    @@ Commit message
         2022-03-30) this was broken by generating a command that never creates
         windows, and therefore vim never shows the diff.
     
    -    In order to show the diff, the windows need to be created first, and
    -    then when they are hidden the diff remains (if hidenoff isn't set).
    -
         The layout support implementation broke the whole purpose of vimdiff3,
         and simply shows MERGED, which is no different from simply opening the
         file with vim.
     
    -    Setting the `hidden` option makes it work as intended.
    +    In order to show the diff, the windows need to be created first, and
    +    then when they are hidden the diff remains (if hidenoff isn't set), but
    +    by setting the `hidden` option the initial buffers are marked as hidden
    +    thus making the feature work.
     
         Suggested-by: Fernando Ramos <greenfoo@u92.eu>
         Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
3:  95bfab5813 = 3:  b8deea49a6 mergetools: vimdiff: silence annoying messages
4:  08f6b2bce2 = 4:  66455480e5 mergetools: vimdiff: fix for diffopt
5:  2bff74f499 < -:  ---------- mergetools: vimdiff: fix single window layouts
6:  39e8277317 ! 5:  9d3a12237d mergetools: vimdiff: rework tab logic
    @@ Commit message
         Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
     
      ## mergetools/vimdiff ##
    +@@ mergetools/vimdiff: gen_cmd_aux () {
    + 	debug_print "LAYOUT    : $LAYOUT"
    + 	debug_print "CMD       : $CMD"
    + 
    +-	if test -z "$CMD"
    +-	then
    +-		CMD="echo" # vim "nop" operator
    +-	fi
    +-
    + 	start=0
    + 	end=${#LAYOUT}
    + 
     @@ mergetools/vimdiff: gen_cmd_aux () {
      
      	# Step 2:
    @@ mergetools/vimdiff: gen_cmd_aux () {
      
     -	if ! test -z "$index_new_tab"
     -	then
    --		before="-tabnew | silent execute 'bufdo diffthis'"
    +-		before="-tabnew"
     -		after="tabnext"
     -		index=$index_new_tab
     -		terminate="true"
    @@ mergetools/vimdiff: gen_cmd () {
     +	IFS=+
     +	for tab in $LAYOUT
     +	do
    -+		test -n "$CMD" && CMD="$CMD | tabnew | silent execute 'bufdo diffthis'"
    ++		if test -z "$CMD"
    ++		then
    ++			CMD="echo" # vim "nop" operator
    ++		else
    ++			CMD="$CMD | tabnew"
    ++		fi
    ++
     +		CMD=$(gen_cmd_aux "$tab" "$CMD")
     +	done
     +	IFS=$oldIFS
      
      
    - 	# Add an extra "-c" option to move to the first tab (notice that we
    + 	# Adjust the just obtained script depending on whether more than one
     @@ mergetools/vimdiff: run_unit_tests () {
    - 	EXPECTED_CMD_08="-c \"set hidden diffopt-=hiddenoff | silent execute 'bufdo diffthis' | leftabove split | leftabove vertical split | 1b | wincmd l | 3b | wincmd j | 4b\" -c \"tabfirst\""
    - 	EXPECTED_CMD_09="-c \"set hidden diffopt-=hiddenoff | silent execute 'bufdo diffthis' | leftabove split | 4b | wincmd j | leftabove vertical split | 1b | wincmd l | 3b\" -c \"tabfirst\""
    - 	EXPECTED_CMD_10="-c \"set hidden diffopt-=hiddenoff | silent execute 'bufdo diffthis' | leftabove vertical split | leftabove split | 1b | wincmd j | leftabove split | 2b | wincmd j | 3b | wincmd l | 4b\" -c \"tabfirst\""
    --	EXPECTED_CMD_11="-c \"set hidden diffopt-=hiddenoff | silent execute 'bufdo diffthis' | -tabnew | silent execute 'bufdo diffthis' | leftabove split | leftabove vertical split | 1b | wincmd l | leftabove vertical split | 2b | wincmd l | 3b | wincmd j | 4b | tabnext | -tabnew | silent execute 'bufdo diffthis' | leftabove vertical split | 2b | wincmd l | 1b | tabnext | -tabnew | silent execute 'bufdo diffthis' | leftabove vertical split | 2b | wincmd l | 3b | tabnext | leftabove vertical split | leftabove split | 1b | wincmd j | leftabove split | 2b | wincmd j | 3b | wincmd l | 4b\" -c \"tabfirst\""
    -+	EXPECTED_CMD_11="-c \"set hidden diffopt-=hiddenoff | silent execute 'bufdo diffthis' | leftabove split | leftabove vertical split | 1b | wincmd l | leftabove vertical split | 2b | wincmd l | 3b | wincmd j | 4b | tabnew | silent execute 'bufdo diffthis' | leftabove vertical split | 2b | wincmd l | 1b | tabnew | silent execute 'bufdo diffthis' | leftabove vertical split | 2b | wincmd l | 3b | tabnew | silent execute 'bufdo diffthis' | leftabove vertical split | leftabove split | 1b | wincmd j | leftabove split | 2b | wincmd j | 3b | wincmd l | 4b\" -c \"tabfirst\""
    - 	EXPECTED_CMD_12="-c \"set hidden diffopt-=hiddenoff | silent execute 'bufdo diffthis' | leftabove vertical split | leftabove split | leftabove vertical split | 1b | wincmd l | 3b | wincmd j | 2b | wincmd l | 4b\" -c \"tabfirst\""
    - 	EXPECTED_CMD_13="-c \"set hidden diffopt-=hiddenoff | silent execute 'bufdo diffthis' | leftabove vertical split | leftabove split | leftabove vertical split | 1b | wincmd l | 3b | wincmd j | 2b | wincmd l | leftabove vertical split | leftabove split | 1b | wincmd j | 3b | wincmd l | 4b\" -c \"tabfirst\""
    --	EXPECTED_CMD_14="-c \"set hidden diffopt-=hiddenoff | silent execute 'bufdo diffthis' | -tabnew | silent execute 'bufdo diffthis' | leftabove vertical split | 2b | wincmd l | 3b | tabnext | leftabove vertical split | 2b | wincmd l | 1b\" -c \"tabfirst\""
    --	EXPECTED_CMD_15="-c \"set hidden diffopt-=hiddenoff | silent execute 'bufdo diffthis' | -tabnew | silent execute 'bufdo diffthis' | leftabove split | leftabove vertical split | 1b | wincmd l | leftabove vertical split | 2b | wincmd l | 3b | wincmd j | 4b | tabnext | -tabnew | silent execute 'bufdo diffthis' | leftabove vertical split | 2b | wincmd l | 1b | tabnext | -tabnew | silent execute 'bufdo diffthis' | leftabove vertical split | 2b | wincmd l | 3b | tabnext | leftabove vertical split | leftabove split | 1b | wincmd j | leftabove split | 2b | wincmd j | 3b | wincmd l | 4b\" -c \"tabfirst\""
    --	EXPECTED_CMD_16="-c \"set hidden diffopt-=hiddenoff | silent execute 'bufdo diffthis' | -tabnew | silent execute 'bufdo diffthis' | leftabove split | leftabove vertical split | 1b | wincmd l | leftabove vertical split | 2b | wincmd l | 3b | wincmd j | 4b | tabnext | -tabnew | silent execute 'bufdo diffthis' | leftabove vertical split | 2b | wincmd l | 1b | tabnext | -tabnew | silent execute 'bufdo diffthis' | leftabove vertical split | 2b | wincmd l | 3b | tabnext | leftabove vertical split | leftabove split | 1b | wincmd j | leftabove split | 2b | wincmd j | 3b | wincmd l | 4b\" -c \"tabfirst\""
    -+	EXPECTED_CMD_14="-c \"set hidden diffopt-=hiddenoff | silent execute 'bufdo diffthis' | leftabove vertical split | 2b | wincmd l | 3b | tabnew | silent execute 'bufdo diffthis' | leftabove vertical split | 2b | wincmd l | 1b\" -c \"tabfirst\""
    -+	EXPECTED_CMD_15="-c \"set hidden diffopt-=hiddenoff | silent execute 'bufdo diffthis' | leftabove split | leftabove vertical split | 1b | wincmd l | leftabove vertical split | 2b | wincmd l | 3b | wincmd j | 4b | tabnew | silent execute 'bufdo diffthis' | leftabove vertical split | 2b | wincmd l | 1b | tabnew | silent execute 'bufdo diffthis' | leftabove vertical split | 2b | wincmd l | 3b | tabnew | silent execute 'bufdo diffthis' | leftabove vertical split | leftabove split | 1b | wincmd j | leftabove split | 2b | wincmd j | 3b | wincmd l | 4b\" -c \"tabfirst\""
    -+	EXPECTED_CMD_16="-c \"set hidden diffopt-=hiddenoff | silent execute 'bufdo diffthis' | leftabove split | leftabove vertical split | 1b | wincmd l | leftabove vertical split | 2b | wincmd l | 3b | wincmd j | 4b | tabnew | silent execute 'bufdo diffthis' | leftabove vertical split | 2b | wincmd l | 1b | tabnew | silent execute 'bufdo diffthis' | leftabove vertical split | 2b | wincmd l | 3b | tabnew | silent execute 'bufdo diffthis' | leftabove vertical split | leftabove split | 1b | wincmd j | leftabove split | 2b | wincmd j | 3b | wincmd l | 4b\" -c \"tabfirst\""
    + 	EXPECTED_CMD_08="-c \"set hidden diffopt-=hiddenoff | echo | leftabove split | leftabove vertical split | 1b | wincmd l | 3b | wincmd j | 4b | tabdo windo diffthis\" -c \"tabfirst\""
    + 	EXPECTED_CMD_09="-c \"set hidden diffopt-=hiddenoff | echo | leftabove split | 4b | wincmd j | leftabove vertical split | 1b | wincmd l | 3b | tabdo windo diffthis\" -c \"tabfirst\""
    + 	EXPECTED_CMD_10="-c \"set hidden diffopt-=hiddenoff | echo | leftabove vertical split | leftabove split | 1b | wincmd j | leftabove split | 2b | wincmd j | 3b | wincmd l | 4b | tabdo windo diffthis\" -c \"tabfirst\""
    +-	EXPECTED_CMD_11="-c \"set hidden diffopt-=hiddenoff | echo | -tabnew | leftabove split | leftabove vertical split | 1b | wincmd l | leftabove vertical split | 2b | wincmd l | 3b | wincmd j | 4b | tabnext | -tabnew | leftabove vertical split | 2b | wincmd l | 1b | tabnext | -tabnew | leftabove vertical split | 2b | wincmd l | 3b | tabnext | leftabove vertical split | leftabove split | 1b | wincmd j | leftabove split | 2b | wincmd j | 3b | wincmd l | 4b | tabdo windo diffthis\" -c \"tabfirst\""
    ++	EXPECTED_CMD_11="-c \"set hidden diffopt-=hiddenoff | echo | leftabove split | leftabove vertical split | 1b | wincmd l | leftabove vertical split | 2b | wincmd l | 3b | wincmd j | 4b | tabnew | leftabove vertical split | 2b | wincmd l | 1b | tabnew | leftabove vertical split | 2b | wincmd l | 3b | tabnew | leftabove vertical split | leftabove split | 1b | wincmd j | leftabove split | 2b | wincmd j | 3b | wincmd l | 4b | tabdo windo diffthis\" -c \"tabfirst\""
    + 	EXPECTED_CMD_12="-c \"set hidden diffopt-=hiddenoff | echo | leftabove vertical split | leftabove split | leftabove vertical split | 1b | wincmd l | 3b | wincmd j | 2b | wincmd l | 4b | tabdo windo diffthis\" -c \"tabfirst\""
    + 	EXPECTED_CMD_13="-c \"set hidden diffopt-=hiddenoff | echo | leftabove vertical split | leftabove split | leftabove vertical split | 1b | wincmd l | 3b | wincmd j | 2b | wincmd l | leftabove vertical split | leftabove split | 1b | wincmd j | 3b | wincmd l | 4b | tabdo windo diffthis\" -c \"tabfirst\""
    +-	EXPECTED_CMD_14="-c \"set hidden diffopt-=hiddenoff | echo | -tabnew | leftabove vertical split | 2b | wincmd l | 3b | tabnext | leftabove vertical split | 2b | wincmd l | 1b | tabdo windo diffthis\" -c \"tabfirst\""
    +-	EXPECTED_CMD_15="-c \"set hidden diffopt-=hiddenoff | echo | -tabnew | leftabove split | leftabove vertical split | 1b | wincmd l | leftabove vertical split | 2b | wincmd l | 3b | wincmd j | 4b | tabnext | -tabnew | leftabove vertical split | 2b | wincmd l | 1b | tabnext | -tabnew | leftabove vertical split | 2b | wincmd l | 3b | tabnext | leftabove vertical split | leftabove split | 1b | wincmd j | leftabove split | 2b | wincmd j | 3b | wincmd l | 4b | tabdo windo diffthis\" -c \"tabfirst\""
    +-	EXPECTED_CMD_16="-c \"set hidden diffopt-=hiddenoff | echo | -tabnew | leftabove split | leftabove vertical split | 1b | wincmd l | leftabove vertical split | 2b | wincmd l | 3b | wincmd j | 4b | tabnext | -tabnew | leftabove vertical split | 2b | wincmd l | 1b | tabnext | -tabnew | leftabove vertical split | 2b | wincmd l | 3b | tabnext | leftabove vertical split | leftabove split | 1b | wincmd j | leftabove split | 2b | wincmd j | 3b | wincmd l | 4b | tabdo windo diffthis\" -c \"tabfirst\""
    ++	EXPECTED_CMD_14="-c \"set hidden diffopt-=hiddenoff | echo | leftabove vertical split | 2b | wincmd l | 3b | tabnew | leftabove vertical split | 2b | wincmd l | 1b | tabdo windo diffthis\" -c \"tabfirst\""
    ++	EXPECTED_CMD_15="-c \"set hidden diffopt-=hiddenoff | echo | leftabove split | leftabove vertical split | 1b | wincmd l | leftabove vertical split | 2b | wincmd l | 3b | wincmd j | 4b | tabnew | leftabove vertical split | 2b | wincmd l | 1b | tabnew | leftabove vertical split | 2b | wincmd l | 3b | tabnew | leftabove vertical split | leftabove split | 1b | wincmd j | leftabove split | 2b | wincmd j | 3b | wincmd l | 4b | tabdo windo diffthis\" -c \"tabfirst\""
    ++	EXPECTED_CMD_16="-c \"set hidden diffopt-=hiddenoff | echo | leftabove split | leftabove vertical split | 1b | wincmd l | leftabove vertical split | 2b | wincmd l | 3b | wincmd j | 4b | tabnew | leftabove vertical split | 2b | wincmd l | 1b | tabnew | leftabove vertical split | 2b | wincmd l | 3b | tabnew | leftabove vertical split | leftabove split | 1b | wincmd j | leftabove split | 2b | wincmd j | 3b | wincmd l | 4b | tabdo windo diffthis\" -c \"tabfirst\""
      
      	EXPECTED_TARGET_01="MERGED"
      	EXPECTED_TARGET_02="LOCAL"
7:  92df35208d < -:  ---------- mergetools: vimdiff: restore selective diff mode
-:  ---------- > 6:  ac1b102da0 mergetools: vimdiff: fix single window layouts
-:  ---------- > 7:  579ec52bc1 mergetools: vimdiff: simplify tabfirst

Comments

Fernando Ramos Aug. 10, 2022, 6:45 p.m. UTC | #1
On 22/08/10 10:46AM, Felipe Contreras wrote:
> Hello,
> 
> These patches make vimdiff3 actually work, along with many single window
> cases.
> 

Thanks Felipe. In this new v4 the code is even cleaner.

I also manually re-tested all the cases (with and without .vimrc) and verified
they work as expected.

Reviewed-by: Fernando Ramos <greenfoo@u92.eu>


PS to Junio: Is it OK to reply with "Reviewed-by" to the cover letter or (for
the next time) should I had individually replied to each of the patches in the
series? Thanks!
Junio C Hamano Aug. 10, 2022, 7:37 p.m. UTC | #2
Fernando Ramos <greenfoo@u92.eu> writes:

> On 22/08/10 10:46AM, Felipe Contreras wrote:
>> Hello,
>> 
>> These patches make vimdiff3 actually work, along with many single window
>> cases.
>> 
>
> Thanks Felipe. In this new v4 the code is even cleaner.
>
> I also manually re-tested all the cases (with and without .vimrc) and verified
> they work as expected.
>
> Reviewed-by: Fernando Ramos <greenfoo@u92.eu>
>
>
> PS to Junio: Is it OK to reply with "Reviewed-by" to the cover letter or (for
> the next time) should I had individually replied to each of the patches in the
> series? Thanks!

You did just fine.  I'll queue with your reviewed-by.

Thanks, both.