git_ui: Count commit title length by characters instead of bytes#57025
Merged
MrSubidubi merged 1 commit intoMay 18, 2026
Merged
Conversation
Switch to `chars().count()` so the multi-byte character handling matches what users perceive as "characters". Extract a shared `commit_title_exceeds_limit` helper used by both the git panel and commit modal, and add unit tests. Release Notes: - Fixed commit title length warning miscounting multi-byte characters in the Git panel and commit modal.
MrSubidubi
approved these changes
May 18, 2026
MrSubidubi
left a comment
Member
There was a problem hiding this comment.
NIce find and fix, even better given that you added a test for this. Thank you and congratulations to your first contribution! 🎉
TomPlanche
pushed a commit
to TomPlanche/zed
that referenced
this pull request
May 20, 2026
…-industries#57025) # What - Replace `title.len()` with `title.chars().count()` in the commit title length check, so the limit is measured in Unicode characters instead of UTF-8 bytes. - Applied in two places that share the same logic: - `crates/git_ui/src/git_panel.rs` — Git panel's inline warning - `crates/git_ui/src/commit_modal.rs` — commit modal's inline warning # Why The commit title length check used str::len(), which returns UTF-8 byte length rather than character count. As a result, titles containing multi-byte characters (Japanese, Chinese, emoji, etc.) triggered the warning far below the configured commit_title_max_length — around 24 characters instead of the default 72. Self-Review Checklist: - [x] I've reviewed my own diff for quality, security, and reliability - [x] Unsafe blocks (if any) have justifying comments - [x] The content is consistent with the [UI/UX checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) - Before https://github.com/user-attachments/assets/a895530c-2f73-470c-97fa-29d9467c14e1 - After https://github.com/user-attachments/assets/ffbe1ba2-0ccc-4b02-87f5-836da7841dd9 - [x] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable Closes #ISSUE Release Notes: - Fixed commit title length check miscounting multi-byte characters as multiple characters.
This was referenced May 27, 2026
TomPlanche
pushed a commit
to TomPlanche/zed
that referenced
this pull request
Jun 2, 2026
…-industries#57025) # What - Replace `title.len()` with `title.chars().count()` in the commit title length check, so the limit is measured in Unicode characters instead of UTF-8 bytes. - Applied in two places that share the same logic: - `crates/git_ui/src/git_panel.rs` — Git panel's inline warning - `crates/git_ui/src/commit_modal.rs` — commit modal's inline warning # Why The commit title length check used str::len(), which returns UTF-8 byte length rather than character count. As a result, titles containing multi-byte characters (Japanese, Chinese, emoji, etc.) triggered the warning far below the configured commit_title_max_length — around 24 characters instead of the default 72. Self-Review Checklist: - [x] I've reviewed my own diff for quality, security, and reliability - [x] Unsafe blocks (if any) have justifying comments - [x] The content is consistent with the [UI/UX checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) - Before https://github.com/user-attachments/assets/a895530c-2f73-470c-97fa-29d9467c14e1 - After https://github.com/user-attachments/assets/ffbe1ba2-0ccc-4b02-87f5-836da7841dd9 - [x] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable Closes #ISSUE Release Notes: - Fixed commit title length check miscounting multi-byte characters as multiple characters.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
title.len()withtitle.chars().count()in the commit title length check, so the limit is measured in Unicode characters instead of UTF-8 bytes.crates/git_ui/src/git_panel.rs— Git panel's inline warningcrates/git_ui/src/commit_modal.rs— commit modal's inline warningWhy
The commit title length check used str::len(), which returns UTF-8 byte length rather than character count. As a result, titles containing multi-byte characters (Japanese, Chinese, emoji, etc.) triggered the warning far below the configured commit_title_max_length — around 24 characters instead of the default 72.
Self-Review Checklist:
I've reviewed my own diff for quality, security, and reliability
Unsafe blocks (if any) have justifying comments
The content is consistent with the UI/UX checklist
Before
Screen.Recording.2026-05-18.at.10.39.24.mov
After
Screen.Recording.2026-05-18.at.10.42.07.mov
Tests cover the new/changed behavior
Performance impact has been considered and is acceptable
Closes #ISSUE
Release Notes: