Skip to content

Conversation

@danilo-leal
Copy link
Member

@danilo-leal danilo-leal commented Dec 20, 2025

Closes #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 EditorStyleswould 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.

Screenshot.2025-12-19.at.9.58.mp4

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.
@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Dec 20, 2025
@danilo-leal danilo-leal changed the title editor: Make TextAlign::Center and TextAlign::Right` work Dec 20, 2025
@mikayla-maki
Copy link
Member

LGTM! We'll need to do some UI work to let components work with focus in a reasonable and intuitive way.... excited for this one!

@mikayla-maki mikayla-maki merged commit 0facdfa into main Dec 20, 2025
27 checks passed
@mikayla-maki mikayla-maki deleted the text-align-center branch December 20, 2025 01:37
huacnlee pushed a commit to longbridge/gpui-component that referenced this pull request Dec 22, 2025
## Description

Fix the input element break caused by PR
zed-industries/zed#45417
ylinwind added a commit to longbridge/gpui-component that referenced this pull request Dec 30, 2025
Ref by GPUI API improve zed-industries/zed#45417

## Screenshot

<img width="533" height="221" alt="image"
src="https://github.com/user-attachments/assets/11c86896-c3b7-40a6-a4f9-41a25e318cd5"
/>

<img width="852" height="798" alt="image"
src="https://github.com/user-attachments/assets/ca13f110-7a0c-4530-90a8-62871711936d"
/>

---------

Co-authored-by: ylinwind <ylinwind@gmail.com>
rtfeldman pushed a commit that referenced this pull request Jan 5, 2026
Closes #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.
LivioGama pushed a commit to LivioGama/zed that referenced this pull request Jan 20, 2026
…ustries#45417)

Closes zed-industries#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.
LivioGama pushed a commit to LivioGama/zed that referenced this pull request Jan 20, 2026
…ustries#45417)

Closes zed-industries#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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement

3 participants