-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
Git - Automatically insert line breaks in git commit messages #2718
Comments
How about a little UI that would tell you that some lines are over 80 characters, and you'd format them yourself? Would that work? |
@joaomoreno Maybe, and actually that was my first thought, though these points came to mind:
Overall I felt that just inserting hard line breaks before committing would be easier, though it does mean writing or finding the code to do the word-wrapping (not sure what the policy is on using external js libraries). There could be a setting something like In any case if it's wanted it is something I'm prepared to work on. |
Good points. As for the UI, I was thinking something like what you get when you try to rename a file to I would like to stay away from automatic wrapping, since it might not do what the user intends to do. Also, we'd have to make it work for non-latin languages too: Arabic, Japanese, Chinese, etc. Not a trivial task. There's a double edge sword in automatic wrapping: turning it on by default would be transparent to the user and, if the outcome is not desirable, he will only detect that when it's too late, probably when the commit was pushed to his server. If we set it off by default, we risk that no one will find and/or use it. What do you think? |
This is an effect used in Github Desktop, as well as elsewhere. Although here the effect is a bit too subtle; I find it a bit difficult to see the limit. In Twitter it's much more visible. Something between the two would be really neat, and maybe with the right balance it could be on by default. However I don't know if the edit box is capable of that kind of rich text, so failing that, yeah the popup that comes up when entering an invalid filename is also nice and that would be ok (as you say, in a less flashy color). |
@joaomoreno Anyone working on this? I'm happy to give it a look. |
@joaomoreno That is a tooltip addressing the first line of the commit message. But I think the proposal described in this issue was about having Visual Studio Code automatically wrap the commit message body to 72 characters per line (the 50/72 convention). In that case, the user's only worry would be the message itself, with VSC wrapping it right after they click 'Commit' and before the actual commit is made. |
@nomicos That was my original wish, yes, but as @joaomoreno pointed out, vscode has to support a lot of languages and correct automatic wrapping in non-latin languages can be really hard. (Eg in vietnamese I think they don't have spaces and you basically have to use a dictionary to know where to break the text.) It's really out of the scope of vscode. What I now do when writing a long commit message, is compose it in blank editor and then copy-paste it in to the commit message box. I would like to see a feature that streamlined this process a bit though. |
I can understand how this might be beyond the scope of the editor but would it be possible to add a tooltip that tells you when you go over the 72 character length on the next line? The 50/72 commit message guideline is almost universal and it would be nice if we could follow it without the extra step of having to edit the commit message after the fact. Alternatively is there a reason we couldn't make the commit message window more like an editor window? There are plugins for automated line wrapping that currently cannot be accessed in the commit message window. It would be excellent if we could access them inside the commit message window. |
I think it would be totally ok if it'll work purely with spaces as we use them writing English. Programming and writing commit messages in English is common approach worldwide, no matter where are you from, and what is your native language. So providing support for all written languages in that specific case seems an overkill. |
From @rmunn
I'm asking for #2718 to be reopened, or for further discussion on the feature to be had in this issue. #2718 was closed because wrapping arbitrary-language text is really difficult (e.g., Thai has no spaces between words, and there is no algorithmic way to correctly break lines in between words; you have to have a Thai dictionary built into your program if you want correct linebreaks in Thai). However, there are two factors that make this an unimportant consideration for Git commit messages:
So the rule for Git commit message word wrapping should be very simple:
This would go a long way towards making VS Code's Git message editor usable. As of right now, I avoid using VS Code's Git integration because it doesn't format Git messages correctly according to the coding standards of just about every project I've worked on. So despite the fact that VS Code has pretty good Git integration for most things, I still just Alt-Tab to a terminal and write my Git commits in Vim, where I can set it up to do the right thing for commit messages (wrap at 72 columns, or at 70 for one project I work on that has slightly stricter rules than most). P.S. Also, as a side effect, I'd like to ask that the Git commit window NOT visually wrap lines that aren't truly wrapped (e.g., the only thing that causes text to go to the next line in the commit window is a real linefeed or CR/LF in the commit message). Instead, if the text goes past the end of the available window size, give us a horizontal scrollbar, which will serve as a cue to resize the Git sidebar to be large enough to fit 72 characters horizontally. And perhaps also there could a button that will automatically resize the Git sidebar to fit the text already in the commit message -- though that's a more "bells and whistles" feature, rather than core functionality. |
Note that my proposal is close to what @stkb originally asked for when he opened this feature request, but there is one specific part of my proposal that is the opposite of what he asked for. He said he wanted the appearance of the Git commit message window to not change, and for the returns or linefeeds to be inserted ("silently", so to speak) after the message composition is finished. Whereas what I am proposing is that the wrapping be visually obvious, so that it's clear precisely where your text is going to be wrapped. This is basically a different proposal, which is why I originally opened a new issue to track it. But we might as well discuss it here, where interested people are already subscribed. |
VS Code version 1.14.2I think the commit message box is terrible and very limiting for such an important feature I use Sublime instead, where a text file is opened and I may enter conveniently a detailed message I'm not sure why it is difficult to do the same here. |
@eaz120 I've requested this feature at #30562. |
Hello everybody. Since this issue remains open, I'd like to throw in my observations and a suggestion. I generally don't commit with VS Code precisely because of this input box. It leaves me unsure of the appearance of the end result when viewed online or in another IDE. I'd like the box to accurately reflect the format, and perhaps expand automatically while editing to look more like a typical editor. I usually use GitEye for all my repository work for several reasons (and the list shrinks as integrations improve). First, I have a full-screen view of the state of my repository, its layout is pleasing, and I get a "visual" sense of the state of my branches, history, and pending work. Second, it is written in Java so I can use it on Windows and Linux. Third (and the part relevant here), is the "Git Files" view - specifically the commit message box. It warns when there is no empty line after first, but doesn't have a separate wrap length from the rest of the text. The example below is a single line of text pasted into the editor. I added only a linefeed after the first line. Wrapping is automatic, and a grey line identifies the wrap point. When committed, the text looks exactly as it did when writing it. If the panel is narrower than the wrap, it will wrap the lines in the editor, then break at the proper location, so it doesn't look great. Simply widening the view automatically gets it to what is shown below. This is an open-source project, so developers here might want to take a look at the code and see if it can be translated to VS Code in a useful way. |
We can now set monospace font in v1.46. |
I would just like to chime in here to echo @waynew . I have been automatically wrapping the body of my commit message to keep lines at 72 characters or less when I author a commit in terminal, and it makes things quick and easy. I don't have to think about what word I'm going to put on the previous line as opposed to the next line. This is a small calculation that I really never want to ever have to think about. As a newer user of VSCode, it was jarring to me that this functionality doesn't exist! 😞 So it would be so nice to just have a lil' setting that allowed you to turn this on. 🙏🏻 |
No updates on this one? |
There is currently a pull request which would add the capability to use the editor for authoring a commit message. The pull request leverages some vscode API that is currently being finalised but as soon as that happens we should be able to make progress on the pull request. |
I noticed the PR was merged a few days ago. Congrats! Is there anything else preventing this issue from being closed? |
@marcusrbrown, I had to revert the change until I fix couple of issues with it. I hope to be able to commit it today. |
Automatic wrapping (subject and/or body) in the Commit Input field on the top-left is still not available, right? |
Yes, we could use a configuration option Edit: I found rewrap combined with #95266 to get me pretty close to what I want. First line has red over 50. All other lines wrap. Maybe there is a way to get perfect with wrapping to rulers but 95% was good enough for me settings.json
Note: Might need to command palette: Rewrap Toggle auto wrap to wake it up. |
Using the complete editor to author commit messages is now part of VS Code. "[git-commit]": {
"editor.rulers": [
72,
50
],
"editor.wordWrap": "wordWrapColumn",
"editor.wordWrapColumn": 72
} |
Nothing for the commit box in the top-left corner? An automatic wrapping option would be very appreciated. See my previous comment. |
I started using the |
Setting the rules from a previous message "[git-commit]": {
"editor.rulers": [
72,
50
],
"editor.wordWrap": "wordWrapColumn",
"editor.wordWrapColumn": 72
} is not working as expected. It wraps the commit message to 72 characters, but it doesn't add newlines, so after you commit, the message won't be wrapped. |
Today's VS Code Insiders release (version details below) contains a new setting,
|
@justingrant yeah it's only a validation warning (which is working on yours). If you want it to auto wrap as you type you'll need to use something like rewrap and the full editor (see my comment above). afaict that's the only way to do this in vs code as of yet. |
@dvnrsn the previous VS Code release had a setting where you could see the number of chars in the field as you were typing. This stopped working in the current release. Is there a way to re-enable it? I'm asking because it was much more convenient to know when the limit was coming, because then I could proactively hit Enter to move to the next line. With that feature removed, now I had to wait until I see the yellow warning squiggle, then back up and remove the last word, then press Enter. That's a lot more unnecessary extra typing. One possible solution could be a small countdown timer like Twitter uses. Like this? |
I'm trying to get into the habit of writing good commit messages. Not sure if this should be the default but it would be really useful if vscode automatically wrapped commit message lines at say 80 chars and inserted line breaks.
I don't mean changing the appearance of the text in the commit message box, just before it's actually committed. The line length could be in an option too.
The text was updated successfully, but these errors were encountered: