edamagit icon indicating copy to clipboard operation
edamagit copied to clipboard

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

Open bmartin opened this issue 2 years ago • 11 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.

bmartin avatar Oct 06 '21 20:10 bmartin

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.

kahole avatar Oct 07 '21 11:10 kahole

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.

dandavison avatar Nov 04 '21 14:11 dandavison

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.

bmartin avatar Nov 04 '21 14:11 bmartin

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"?

kahole avatar Nov 05 '21 06:11 kahole

+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?

matklad avatar Nov 10 '21 09:11 matklad

@kahole

What about "abort"?

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

jacobemcken avatar Nov 14 '22 11:11 jacobemcken

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?

matklad avatar Jan 10 '24 19:01 matklad

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'"
    }

jacobemcken avatar Jan 10 '24 20:01 jacobemcken

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.

kahole avatar Jan 11 '24 15:01 kahole

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?

kahole avatar Jan 11 '24 15:01 kahole

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" },

matklad avatar Jan 11 '24 15:01 matklad