# git: Use version control colors in diff hunk line numbers \(\#59973\) · gitcafe/zed

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

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

Visibility: public

Requested revision: adedf355d5207337d243d292d14092135325f885

Requested commit: adedf355d5207337d243d292d14092135325f885

Commit: adedf355d5207337d243d292d14092135325f885

Tree: fa372b78e5edce4946f0adf7eaef6a9be9b01c3a

Author: Dino

Committer: GitHub

## Message

```
git: Use version control colors in diff hunk line numbers (#59973)

# Objective

When diff hunks are expanded, reading the line numbers can be a little
hard due to the contrast between `editor.line_number` and both
`editor.diff_hunk.deleted.background` and
`editor.diff_hunk.added.background`. In order to make it easier for
these line numbers to stand out, the actual `version_control` colors,
respective to each diff hunk, can be used to color the line number.

## Solution

Luckily, the line numbers color was already dynamically decided on
`EditorElement::layout_line_numbers` depending on whether the line had a
breakpoint or it was active (part of a selection). The information on
whether the row for which the line was being laid out belonged to a diff
hunk is also already available on the `Gutter::row_infos`.

As such, this change was easy to achieve by simply updating
`EditorElement::layout_line_numbers` to take into consideration each
row's `RowInfo::diff_status` and mapping each status to a
`version_control` color, ignoring the `Modified` variant, as that should
never happen.

## Testing

Manually tested against a repository that has added, deleted and
modified changes. Differences can be seen in the `Showcase` section.

## Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [ ] Unsafe blocks (if any) have justifying comments
- [x] The content adheres to Zed's UI standards
([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
and
[icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md)
guidelines)
- [ ] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

## Showcase

<details>
  <summary>Before</summary>
  
<img width="2744" height="2994"
alt="version_control_line_numbers_before"
src="https://github.com/user-attachments/assets/75d160a7-e0cc-4c9d-8fdd-4cab5cc6eefb"
/>
</details>

<details>
  <summary>After</summary>

<img width="2744" height="2994" alt="version_control_line_numbers_after"
src="https://github.com/user-attachments/assets/887fdb6a-34c6-4331-b750-4d3bea6fcd77"
/>
</details>
---

Release Notes:

- Improved line number colors in diff hunks to match the version control
colors
```

## Parents

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

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