# git_ui: Count commit title length by characters instead of bytes \(\#57025\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/8ce894b909ec3cbbb84e1bc8eedc542a5f975c61)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 8ce894b909ec3cbbb84e1bc8eedc542a5f975c61

Requested commit: 8ce894b909ec3cbbb84e1bc8eedc542a5f975c61

Commit: 8ce894b909ec3cbbb84e1bc8eedc542a5f975c61

Tree: 0346a59ad53f33a731071db1a2a80f548cb54473

Author: Koya Masuda

Committer: GitHub

## Message

```
git_ui: Count commit title length by characters instead of bytes (#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.
```

## Parents

- [533e975df091b1547ec44e0eb5e15de8b00d627f](https://git.cafe/gitcafe/zed/commit/533e975df091b1547ec44e0eb5e15de8b00d627f?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/8ce894b909ec3cbbb84e1bc8eedc542a5f975c61?format=markdown)
