vim-merginal icon indicating copy to clipboard operation
vim-merginal copied to clipboard

Map <CR> to checkout the branch under cursor

Open mcepl opened this issue 7 years ago • 4 comments

It seems to me that the most intuitive action one needs to do with the Merginal is to switch branches. Is it just my stupidity that I cannot find it in documentation, or CR is really not mapped to call b:merginal.checkoutBranch()<CR>? Shouldn't it be so?

mcepl avatar Apr 18 '18 09:04 mcepl

<Cr> is not mapped to anything in the Merginal buffer. I can see your point about it being the most intuitive, but I'm kind of worried about mapping <Cr> to something that modifies the files on the disk.

In the files diff buffers <Cr> is mapped to open the file under the cursor, but that action is easily reversible with <C-o>. Checking out a branch is not trivially reversible, so I find it too dangerous a command to be mapped to <Cr>.

idanarye avatar Apr 19 '18 00:04 idanarye

Well, git checkout <branch> (without -f) fails if any changes in the working tree (or even index) would be destroyed by it. I guess, that command was meant to be safe for this.

mcepl avatar Apr 19 '18 05:04 mcepl

@mcepl I wanted the same feature. I forked vim-merginal, added support for filetypes, and then mapped Enter to checkout a branch when in a merginal buffer.

See:

[1] https://github.com/idanarye/vim-merginal/pull/51/files#diff-807cda537f794aae62e7cc4b5ef98837dc9f780c2f3bb1aa1083cbb071aa9642R135 [2] https://github.com/tecfu/.vim/blob/develop/plugins.vim#L269-L271

@idanarye Thanks for your awesome plugin

tecfu avatar Jun 05 '22 20:06 tecfu

@mcepl This issue is now resolved after most recent merge to master. See here for implementation how-to.

tecfu avatar Jun 06 '22 19:06 tecfu