git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* mergetools: wrong window selected for vimdiff1
@ 2023-01-05 18:47 Sebastián Mancilla
  0 siblings, 0 replies; only message in thread
From: Sebastián Mancilla @ 2023-01-05 18:47 UTC (permalink / raw)
  To: git

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 edit

Also 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:

>          *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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-01-05 18:56 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-05 18:47 mergetools: wrong window selected for vimdiff1 Sebastián Mancilla

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).