Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrap in commit message edit box #224

Closed
segevfiner opened this issue Jul 18, 2020 · 5 comments
Closed

Rewrap in commit message edit box #224

segevfiner opened this issue Jul 18, 2020 · 5 comments

Comments

@segevfiner
Copy link

Git commit messages are conventially wrapped to a certain line length (First line to 50-70, shouldn't be rewrapped even if longer, following paragraphs to 80), this even has a warning about it builtin to the commit message box in VS Code. Yet there is no command to automatically rewrap the message to such limits like this extension does.

It would be really useful if this extension would have worked for the Git command message box, obeying the specific rules conventially used for it.

Though I'm not sure if VS Code supplies the API to do so.

@stkb
Copy link
Owner

stkb commented Jul 20, 2020

There's a very long/old issue microsoft/vscode#2718 that I opened asking for auto hard wrapping for commit messages, though I actually no longer agree that automatic wrapping there is the way to go.

As you say there's no VSCode API to hook into its own small commit message boxes.

I think the better way however, is to write commit messages in a full VSCode editor pane, so you get all the editing tools (including Rewrap) and can see exactly how the message looks before committing. So this is how I have this set up:

I have VSCode set up as my git editor with git config --global core.editor 'path/to/vscode.exe' --wait -n (you can also use a GIT_EDITOR environment variable instead).

Then in my settings.json I have this to set the rulers in git commits:

"[git-commit]": {
    "editor.rulers": [72, 50]
},

Then when I want to commit, it's just git commit in the terminal, and VSCode opens in a new window to write the message. After you save and close, it's committed.

(Actually what I more often do is make small commits with brief messages just using the message box in the sidebar, then when I'm happy with the change I'll use interactive rebase to squash the commits and write a "proper" message in the full editor then.)

However it would be nice if VSCode all this easier, and you may want to keep an eye on the PR microsoft/vscode#95266 which should do exactly that.

BTW you make a good point that the first line should never be wrapped in a git-commit document. It's maybe something I could add.

@segevfiner
Copy link
Author

Yeah I'm familiar with the idea of using VS Code as the Git editor, didn't get around to trying it to see if I like it that way or not. And that doesn't integrate with the Git commit text area in VS Code of course, just when running Git from CLI.

I also remember the experience in Atom where they just have a button to pop to a full editor and back from the Git commit text area. I think they didn't do anything fancy with core.editor/GIT_EDITOR or stuff like that, works just the same as the small text box, just using the full editor. It probably just sends the text to the git commit command once you press commit. That's of course something for a different discussion and is in VS Code rather than this extension.

Even if a feature to use the full editor, in whatever capacity, will be implemented, it would still be nice to have such commands like rewrap be able to work in the small Git commit text area, will save the need to open the full editor just for rewrap. Maybe this needs an issue against VS Code if there isn't only one so they can consider adding such API.

Thanks for answering.

P.S. Despite all the amazing work & features VS Code has, sometimes it really feels like the Git UX has been kinda neglected and could really use an overhaul. Don't you think?

@stkb
Copy link
Owner

stkb commented Jul 21, 2020

Yeah I agree it would be nice to have an easy way to switch between the small textbox and full editor for commit messages. We'll have to see what that PR brings.

I find VSCode really helps for git with staging files, and resolving merge conflicts. I agree you could say the rest is lacking but to be honest I'm happy using the command line and git gui for the rest.

I'm going to close this because there's nothing really that can be done here.

@segevfiner
Copy link
Author

Opened microsoft/vscode#103128

@segevfiner
Copy link
Author

@stkb I found that it is possible to edit the commit input box via this API: https://github.com/microsoft/vscode/blob/648bcd18aa05bef3b51e4873a4dd871a43b49dc1/extensions/git/src/api/git.d.ts#L165

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants