mergetools: wrong window selected for vimdiff1
- From
- Sebastián Mancilla <smancill@smancill.dev>
- Date
- Jan 5, 2023, 18:47 UTC
- Message-ID
- <167294445271.7.3739319158947040124.89448053@smancill.dev>
The layout for the vimdiff1 mergetool is "@LOCAL,REMOTE". From the man page:
o layout = "@LOCAL,REMOTE"
When MERGED is not present in the layout, you must "mark" one
of the buffers with an asterisk. That will become the buffer
you need to edit and save after resolving the conflicts. ------------------------------------------
| | |
| | |
| | |
| LOCAL | REMOTE |
| | |
| | |
| | |
------------------------------------------But after opening the buffers, the cursor is in the *right window*.
This is confusing, since it makes you think the right buffer is the one that needs to be edited, instead of the left one.
Debug output (the make-conflicts.sh script in this repository [0] can be used to quickly test a file with conflicts):
Merging:
poem.txt Normal merge conflict for 'poem.txt':
{local}: modified file
{remote}: modified file LAYOUT : @LOCAL,REMOTE
CMD : echo
NESTED MIN: 0
CLEAN : @LOCAL,REMOTE LAYOUT : @LOCAL
CMD : echo | leftabove vertical split
NESTED MIN: 0
CLEAN : @LOCAL LAYOUT : REMOTE
CMD : echo | leftabove vertical split | 1b | wincmd l
NESTED MIN: 0
CLEAN : REMOTE FINAL CMD : -c "set hidden diffopt-=hiddenoff | echo |
leftabove vertical split | 1b | wincmd l | 3b | execute 'tabdo windo
diffthis' | tabfirst"
FINAL TAR : LOCAL
4 files to editAlso note that when vimdiff1 was introduced by 30bb8088af (mergetools/vimdiff: add vimdiff1 merge tool variant, 2021-02-13), Vim echoed a nice message to remember which buffer shall be edited:
> + *vimdiff1) > + "$merge_tool_path" -f -d \ > + -c 'echon "Resolve conflicts leftward then save. Use :cq to abort."' \ > + "$LOCAL" "$REMOTE"
But with the refactor done by 0041797449 (vimdiff: new implementation with layout support, 2022-03-30), now the message is gone:
Show 12 quoted lines
> *vimdiff1) > - "$merge_tool_path" -f -d \ > - -c 'echon "Resolve conflicts leftward then save. Use :cq to abort."' \ > - "$LOCAL" "$REMOTE" > - ret="$?" > - if test "$ret" -eq 0 > - then > - cp -- "$LOCAL" "$MERGED" > - fi > - return "$ret" > + layout="@LOCAL,REMOTE" > ;;
[0]: https://github.com/whiteinge/diffconflicts/tree/master/_utils
-- Sebastián Mancilla