kahole / edamagit

Magit for VSCode

Home Page:https://marketplace.visualstudio.com/items?itemName=kahole.magit

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Usability Request: Remove "Ctrl-C Ctrl-C" from COMMIT_EDITMSG mode

bmartin opened this issue · comments

Proposed Change:

Remove special "Ctrl-c Ctrl-c" keystroke In the commit message editing mode. Instead, the users can use the standard "Ctrl-s Ctrl-w" to save and close the file in the editor. This way "Ctrl-c" is available for copying content.

Rationale

vscode users likely already have a simple way to deal with "save and close a file", either with the default key bindings or something custom to their setup. Since C-c C-c is really just saving and closing the buffer under the hood, there is no reason to add it.

Users with the default key-bindings will definitely be surprised to find that they cannot copy text in a commit message. It has burned me when I tried to copy reproduction steps from text and then paste it into a terminal to verify a fix.

This will be a muscle memory change for users with a long history with magit, but one that should be pretty quick to get used to.

Makes sense, but I don't see a nice replacement for C-c C-k. I think you might be replacing accidental commits on copy with accidental commits on abort.

Just a note: for Mac users there's no conflict here: copy is Cmd-c and the traditional emacs "execute & dismiss" operation used widely in e.g. magit and org-mode is Ctrl-c Ctrl-c. So for that group of users at least I think it would be a shame/inappropriate to get rid of the Ctrl-c Ctrl-c binding which, as you say, is muscle memory for a magit user.

I note that most equivalent git integrations in VSCode such as gitlens use CTRL+Enter for the confirm action. I don't know if there is a way to specify "use the correct confirm action key for this platform", but CTRL+Enter would be a safe choice.

I note that most equivalent git integrations in VSCode such as gitlens use CTRL+Enter for the confirm action. I don't know if there is a way to specify "use the correct confirm action key for this platform", but CTRL+Enter would be a safe choice.

What about "abort"?

+1 as Emacs expat, I appreciate that C-c just works, but it gets in a way when I need to copy text. Moreover, most VS Code users are not Emacs users, and for them C-c is just O_o.

I wonder if Ctrl-Enter for commit/Escape to abort would work?

@kahole

What about "abort"?

Whould Esc (Escape) work as matklad suggested? Seems very intuitive to me?

In case this is helpful for anyone, here's how I get ctrl+c back and use ctrl+alt+Enter for submitting a commit:

  { "key": "ctrl+alt+Enter",        "command": "magit.save-and-close-editor",
                                    "when": "editorTextFocus && editorLangId == 'git-rebase'" },
  { "key": "ctrl+c ctrl+c",         "command": "-magit.save-and-close-editor" },
  { "key": "ctrl+c ctrl+k",         "command": "-magit.clear-and-abort-editor" },

I don't map anything to clear-and-abort, somehow I don't need that I think?

I wanted Ctrl + Enter for comitting and Esc for cancelling, so I added the following to keybindings.json (I was unable to add Esc using the UI):

    {
        "key": "ctrl+enter",
        "command": "magit.save-and-close-editor",
        "when": "editorTextFocus && editorLangId == 'git-commit'"
    },
    {
        "key": "ctrl+c ctrl+c",
        "command": "-magit.save-and-close-editor",
        "when": "editorTextFocus && editorLangId == 'git-commit'"
    },
    {
        "key": "ctrl+enter",
        "command": "magit.save-and-close-editor",
        "when": "editorTextFocus && editorLangId == 'git-rebase'"
    },
    {
        "key": "ctrl+c ctrl+c",
        "command": "-magit.save-and-close-editor",
        "when": "editorTextFocus && editorLangId == 'git-rebase'"
    },
    {
        "key": "escape",
        "command": "magit.clear-and-abort-editor",
        "when": "editorTextFocus && editorLangId == 'git-commit'"
    },
    {
        "key": "ctrl+c ctrl+k",
        "command": "-magit.clear-and-abort-editor",
        "when": "editorTextFocus && editorLangId == 'git-commit'"
    },
    {
        "key": "escape",
        "command": "magit.clear-and-abort-editor",
        "when": "editorTextFocus && editorLangId == 'git-rebase'"
    },
    {
        "key": "ctrl+c ctrl+k",
        "command": "-magit.clear-and-abort-editor",
        "when": "editorTextFocus && editorLangId == 'git-rebase'"
    }

I'm open to this Esc for abort and Ctrl+Enter for commit.
It probably means breaking a bunch of people's workflows, but adding the keybindings back is quite simple.

The defaults for edamagit shouldnt break copying from the commit message editor.

Although, Esc seems kind of scary. Escape is used to dismiss suggestions in the editor, and normally doesn't do anything very destructive in the editor. Also, conflict with exiting insert mode in VSCodeVim.
Could Ctrl+Escape be a good alternative?

I've actually spend some time trying to figure out the right key for aborting, and couldn't find any. The closest thing from the default keybindings would be:

{ "key": "ctrl+; ctrl+x",         "command": "testing.cancelRun" },

The rational for Ctrl+Alt+Enter is that Ctrl+Enter is occupied:

{ "key": "ctrl+enter",            "command": "editor.action.insertLineAfter",
                                     "when": "editorTextFocus && !editorReadonly" },

and the ctrl+alt is used as submit by search:

{ "key": "ctrl+alt+enter",        "command": "editor.action.replaceAll",
                                     "when": "editorFocus && findWidgetVisible" },