git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] mergetool: reorder vim/gvim buffers in three-way diffs

From
Dickson Wong <dicksonwong@gmail.com>
Date
Jan 29, 2016, 02:18 UTC
Message-ID
<1454033894-49954-1-git-send-email-dicksonwong@gmail.com>

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
Next: Junio C Hamano
Message 1 of 12 in “mergetool: reorder vim/gvim buffers in three-way diffs”
  1. mergetool: reorder vim/gvim buffers in three-way diffsDickson Wong, Jan 29, 2016
  2. Junio C HamanoJan 29, 2016
  3. Junio C HamanoFeb 9, 2016
  4. Michael J GruberFeb 10, 2016
  5. Junio C HamanoFeb 10, 2016
  6. Michael J GruberFeb 11, 2016
  7. Junio C HamanoFeb 11, 2016
  8. Dickson WongFeb 11, 2016
  9. Junio C HamanoFeb 11, 2016
  10. Dickson WongFeb 11, 2016
  11. David AguilarFeb 11, 2016
  12. Junio C HamanoFeb 12, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.