@@ -55,6 +55,30 @@ substring () {
echo "$STRING" | cut -c$(( START + 1 ))-$(( START + $LEN ))
}
+get_buf () {
+ target=$(echo "$1" | sed 's:[ @();|-]::g')
+ buf="1"
+
+ if test "$target" = "LOCAL"
+ then
+ buf="1"
+
+ elif test "$target" = "BASE"
+ then
+ buf="2"
+
+ elif test "$target" = "REMOTE"
+ then
+ buf="3"
+
+ elif test "$target" = "MERGED"
+ then
+ buf="4"
+ fi
+
+ echo "$buf"
+}
+
gen_cmd_aux () {
# Auxiliary function used from "gen_cmd()".
# Read that other function documentation for more details.
@@ -257,27 +281,8 @@ gen_cmd_aux () {
# If we reach this point, it means there are no separators and we just
# need to print the command to display the specified buffer
- target=$(substring "$LAYOUT" "$start" "$(( end - start ))" | sed 's:[ @();|-]::g')
-
- if test "$target" = "LOCAL"
- then
- CMD="$CMD | 1b"
-
- elif test "$target" = "BASE"
- then
- CMD="$CMD | 2b"
-
- elif test "$target" = "REMOTE"
- then
- CMD="$CMD | 3b"
-
- elif test "$target" = "MERGED"
- then
- CMD="$CMD | 4b"
-
- else
- CMD="$CMD | ERROR: >$target<"
- fi
+ buf=$(get_buf $(substring "$LAYOUT" "$start" "$(( end - start ))"))
+ CMD="$CMD | ${buf}b"
echo "$CMD"
return
@@ -319,8 +324,8 @@ gen_cmd () {
if ! echo "$LAYOUT" | grep ",\|/" >/dev/null
then
- CMD=$(gen_cmd_aux "$LAYOUT")
- FINAL_CMD="-c \"$CMD | bufdo diffthis\" -c \"tabfirst\""
+ buf=$(get_buf "$LAYOUT")
+ FINAL_CMD="-c \"echo | ${buf}b | bufdo diffthis\" -c \"tabfirst\""
return
fi
Now the single window mode can avoid gen_cmd_aux() altogether. No functional changes. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> --- mergetools/vimdiff | 51 +++++++++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 23 deletions(-)