git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dickson Wong <dicksonwong@gmail.com>
To: git@vger.kernel.org
Cc: Dickson Wong <dicksonwong@gmail.com>
Subject: [PATCH] mergetool: reorder vim/gvim buffers in three-way diffs
Date: Thu, 28 Jan 2016 18:18:14 -0800	[thread overview]
Message-ID: <1454033894-49954-1-git-send-email-dicksonwong@gmail.com> (raw)

When invoking default (g)vimdiff three-way merge, the merged file is
loaded as the first buffer but moved to the bottom as the fourth window.
This causes a disconnect between vim commands that operate on window
positions (e.g. CTRL-W_w) and those that operate on buffer index (e.g.
do/dp).

This change reorders the buffers to have the same index as windows while
keeping the cursor default to the merged result as the bottom window.

Signed-off-by: Dickson Wong <dicksonwong@gmail.com>
---
 mergetools/vimdiff | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mergetools/vimdiff b/mergetools/vimdiff
index 1ddfbfc..74ea6d5 100644
--- a/mergetools/vimdiff
+++ b/mergetools/vimdiff
@@ -2,22 +2,22 @@ diff_cmd () {
 	"$merge_tool_path" -R -f -d \
 		-c 'wincmd l' -c 'cd $GIT_PREFIX' "$LOCAL" "$REMOTE"
 }
 
 merge_cmd () {
 	touch "$BACKUP"
 	case "$1" in
 	gvimdiff|vimdiff)
 		if $base_present
 		then
-			"$merge_tool_path" -f -d -c 'wincmd J' \
-				"$MERGED" "$LOCAL" "$BASE" "$REMOTE"
+			"$merge_tool_path" -f -d -c '4wincmd w | wincmd J' \
+				"$LOCAL" "$BASE" "$REMOTE" "$MERGED"
 		else
 			"$merge_tool_path" -f -d -c 'wincmd l' \
 				"$LOCAL" "$MERGED" "$REMOTE"
 		fi
 		;;
 	gvimdiff2|vimdiff2)
 		"$merge_tool_path" -f -d -c 'wincmd l' \
 			"$LOCAL" "$MERGED" "$REMOTE"
 		;;
 	gvimdiff3|vimdiff3)
-- 
2.6.2

             reply	other threads:[~2016-01-29  2:28 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-29  2:18 Dickson Wong [this message]
2016-01-29 18:45 ` [PATCH] mergetool: reorder vim/gvim buffers in three-way diffs Junio C Hamano
2016-02-09 22:25   ` Junio C Hamano
2016-02-10 14:40     ` Michael J Gruber
2016-02-10 17:45       ` Junio C Hamano
2016-02-11 15:44         ` Michael J Gruber
2016-02-11 16:03           ` Junio C Hamano
2016-02-11 19:24             ` Dickson Wong
2016-02-11 19:31               ` Junio C Hamano
2016-02-11 20:10                 ` Dickson Wong
2016-02-11 21:15             ` David Aguilar
2016-02-12 18:15               ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1454033894-49954-1-git-send-email-dicksonwong@gmail.com \
    --to=dicksonwong@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).