-
Notifications
You must be signed in to change notification settings - Fork 30.4k
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 commit box does not warn long messages #21144
Comments
Hey @joaomoreno! I'd very much like this feature after starting using visual studio code. Can I pick this up and submit a patch? If so, something I should keep in mind? |
I admire your effort, but this won't be a simple task, since git is now an extension. You'll be limited by the extension API. If you want to contribute to VS Code I suggest to go through the |
I still miss it a lot. There are a couple stupid things I do to work around this a bit though:
then resizing the sidebar to make a message >50 characters wrap to the next line. Messing with the css does make a warning pop up in vscode that it's unsupported though, and it will have to be redone every time a new version of vscode is installed |
You gave me an idea and it totally works on the Mac version (1.17.2)!!! (I don't know if you have a Mac, so this might only be for Mac users). You can add additional JavaScript to the VS Code app, so why not add some DOM-manipulation!?! You can accomplish it using the following steps:
try {
window.addEventListener("keyup", gitCharacterCounter, false);
function gitCharacterCounter() {
var mirror = document.getElementsByClassName("mirror")[0]
if (mirror) {
var length = mirror.textContent.replace('Message (press Cmd+Enter to commit)', '').length
var titleLabel = document.getElementsByClassName("title-label")[0]
var titleSpan = titleLabel.getElementsByTagName('span')[0]
var labelBase = titleSpan.textContent.replace(/\([0-9]{0,100}\)/,'')
titleSpan.innerHTML = labelBase + ' (' + length + ')'
}
};
}
catch (e) {
console.log(e)
}
note: I updated the code to wrap it in a try/catch, since window might be undefined sometimes |
@scottclayton Wow, that’s an amazing hack! I found the actual code responsible for those elements. I think adding a counter to the actual Would love to work with you to get a pull request in! |
@jayjun Thanks! I'm totally on board for working on a PR for restoring the feature—I've been missing it nearly every day since its removal. I think implementing a running count of characters plus a warning when a certain length is exceeded—(configurable as settings for whether or not the warning happens and also what the length limit would be for the warning when exceeded)—would be a nice approach, since we would be getting the character count for free every time we check if the length exceeds the limit anyway. What do you think? I couldn't see any active PRs for the feature, so I guess this is our time to shine. I have no idea how people on github communicate with one another, so I've made a gist for us to discuss it if you're keen: https://gist.github.com/scottclayton/2c463746002ed2070ab1914bb7c7cafb |
@scottclayton I submitted a WIP pull request. Let’s continue our discussion/hacking there! |
Fixed by #36890 |
Testing #20999
There is a setting to enable warning for long commit messages. Even though it is enabled, there is no warning shown for long messages. Also it would be helpful to update the description of the setting about the length of the message
The text was updated successfully, but these errors were encountered: