mergetools: vimdiff: rework tab logic
If we treat tabs especially, the logic becomes much simpler. Cc: Fernando Ramos <greenfoo@u92.eu> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Reviewed-by: Fernando Ramos <greenfoo@u92.eu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
60184ab4d3
commit
ffcc33f6a6
@ -66,11 +66,6 @@ gen_cmd_aux () {
|
|||||||
debug_print "LAYOUT : $LAYOUT"
|
debug_print "LAYOUT : $LAYOUT"
|
||||||
debug_print "CMD : $CMD"
|
debug_print "CMD : $CMD"
|
||||||
|
|
||||||
if test -z "$CMD"
|
|
||||||
then
|
|
||||||
CMD="echo" # vim "nop" operator
|
|
||||||
fi
|
|
||||||
|
|
||||||
start=0
|
start=0
|
||||||
end=${#LAYOUT}
|
end=${#LAYOUT}
|
||||||
|
|
||||||
@ -144,11 +139,10 @@ gen_cmd_aux () {
|
|||||||
|
|
||||||
# Step 2:
|
# Step 2:
|
||||||
#
|
#
|
||||||
# Search for all valid separators ("+", "/" or ",") which are *not*
|
# Search for all valid separators ("/" or ",") which are *not*
|
||||||
# inside parenthesis. Save the index at which each of them makes the
|
# inside parenthesis. Save the index at which each of them makes the
|
||||||
# first appearance.
|
# first appearance.
|
||||||
|
|
||||||
index_new_tab=""
|
|
||||||
index_horizontal_split=""
|
index_horizontal_split=""
|
||||||
index_vertical_split=""
|
index_vertical_split=""
|
||||||
|
|
||||||
@ -182,14 +176,7 @@ gen_cmd_aux () {
|
|||||||
then
|
then
|
||||||
current=$c
|
current=$c
|
||||||
|
|
||||||
if test "$current" = "+"
|
if test "$current" = "/"
|
||||||
then
|
|
||||||
if test -z "$index_new_tab"
|
|
||||||
then
|
|
||||||
index_new_tab=$i
|
|
||||||
fi
|
|
||||||
|
|
||||||
elif test "$current" = "/"
|
|
||||||
then
|
then
|
||||||
if test -z "$index_horizontal_split"
|
if test -z "$index_horizontal_split"
|
||||||
then
|
then
|
||||||
@ -219,14 +206,7 @@ gen_cmd_aux () {
|
|||||||
|
|
||||||
terminate="false"
|
terminate="false"
|
||||||
|
|
||||||
if ! test -z "$index_new_tab"
|
if ! test -z "$index_horizontal_split"
|
||||||
then
|
|
||||||
before="-tabnew"
|
|
||||||
after="tabnext"
|
|
||||||
index=$index_new_tab
|
|
||||||
terminate="true"
|
|
||||||
|
|
||||||
elif ! test -z "$index_horizontal_split"
|
|
||||||
then
|
then
|
||||||
before="leftabove split"
|
before="leftabove split"
|
||||||
after="wincmd j"
|
after="wincmd j"
|
||||||
@ -333,7 +313,21 @@ gen_cmd () {
|
|||||||
|
|
||||||
# Obtain the first part of vim "-c" option to obtain the desired layout
|
# Obtain the first part of vim "-c" option to obtain the desired layout
|
||||||
|
|
||||||
CMD=$(gen_cmd_aux "$LAYOUT")
|
CMD=
|
||||||
|
oldIFS=$IFS
|
||||||
|
IFS=+
|
||||||
|
for tab in $LAYOUT
|
||||||
|
do
|
||||||
|
if test -z "$CMD"
|
||||||
|
then
|
||||||
|
CMD="echo" # vim "nop" operator
|
||||||
|
else
|
||||||
|
CMD="$CMD | tabnew"
|
||||||
|
fi
|
||||||
|
|
||||||
|
CMD=$(gen_cmd_aux "$tab" "$CMD")
|
||||||
|
done
|
||||||
|
IFS=$oldIFS
|
||||||
|
|
||||||
|
|
||||||
# Adjust the just obtained script depending on whether more than one
|
# Adjust the just obtained script depending on whether more than one
|
||||||
@ -565,12 +559,12 @@ run_unit_tests () {
|
|||||||
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_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_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_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_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_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_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 | -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_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 | -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 | 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_01="MERGED"
|
||||||
EXPECTED_TARGET_02="LOCAL"
|
EXPECTED_TARGET_02="LOCAL"
|
||||||
|
Loading…
Reference in New Issue
Block a user