# editor: Make \`TextAlign::Center\` and \`TextAlign::Right\` work \(\#45417\) · gitcafe/zed

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

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

Visibility: public

Requested revision: 0facdfa5caedb1cacf92d435697c83dad1e66ea4

Requested commit: 0facdfa5caedb1cacf92d435697c83dad1e66ea4

Commit: 0facdfa5caedb1cacf92d435697c83dad1e66ea4

Tree: 0595576d6ec34ca2f36ee57b4616f9336d72d9c7

Author: Danilo Leal

Committer: GitHub

## Message

```
editor: Make `TextAlign::Center` and `TextAlign::Right` work (#45417)

Closes https://github.com/zed-industries/zed/issues/43208

This PR essentially unblocks the editable number field. The function
that shapes editor lines was hard-coding text alignment to the left,
meaning that whatever different alignment we'd pass through
`EditorStyles`would be ignored. To solve this, I just added a text align
and align width fields to the line paint function and updated all call
sites keeping the default configuration. Had to also add an
`alignment_offset()` helper to make sure the cursor positioning, the
selection background element, and the click-to-focus functionality were
kept in-sync with the non-left aligned editor.

Then... the big star of the show here is being able to add the `mode`
method to the number field, which uses `TextAlign::Center`, thus making
it work as we designed it to work.


https://github.com/user-attachments/assets/3539c976-d7bf-4d94-8188-a14328f94fbf

Next up, is turning the number filed to edit mode where applicable.

Release Notes:

- Fixed a bug where different text alignment configurations (i.e.,
center and right-aligned) wouldn't take effect in editors.
```

## Parents

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

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