Skip to content

gpui: Don't start a wrapped line with closing punctuation or a slash - #62743

Merged
Veykril merged 2 commits into
zed-industries:mainfrom
alii:gpui-wrap-punctuation
Aug 26, 2026
Merged

gpui: Don't start a wrapped line with closing punctuation or a slash#62743
Veykril merged 2 commits into
zed-industries:mainfrom
alii:gpui-wrap-punctuation

Conversation

@alii

@alii alii commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Objective

LineWrapper treats every punctuation character as a break opportunity, so a wrap can land right before !, ?, /, ), ], }, a closing quote or an ellipsis. Text such as please fix this plz!, 8.0/8.0, cli/install, (see) or “quoted” then wraps with the closing mark orphaned at the start of the next line.

Solution

Add the "UAX 14 LB13 rule" to LineWrapper::is_word_char, which is to not break before ! ? / ) ] } " ” » …

Testing

Added unit tests and manually tested myself with a long paragraph in a gpui app.

Self-Review Checklist:

  • I've reviewed my own diff for quality, security, and reliability
  • Unsafe blocks (if any) have justifying comments
  • The content adheres to Zed's UI standards
  • Tests cover the new/changed behavior
  • Performance impact has been considered and is acceptable (one extra matches! per character in the wrap loop)

Release Notes:

  • Fixed text wrapping so closing punctuation and slashes never begin a wrapped line.

@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Aug 17, 2026
@SomeoneToIgnore SomeoneToIgnore added area:gpui GPUI rendering framework support area:editor Feedback for code editing, formatting, editor iterations, etc labels Aug 17, 2026
@maxdeviant maxdeviant changed the title gpui: don't start a wrapped line with closing punctuation or a slash gpui: Don't start a wrapped line with closing punctuation or a slash Aug 17, 2026
@alii

This comment was marked as outdated.

@alii
alii force-pushed the gpui-wrap-punctuation branch from 0c391ec to 260c194 Compare August 17, 2026 17:02

@Veykril Veykril left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@Veykril
Veykril enabled auto-merge August 26, 2026 08:00
@Veykril Veykril self-assigned this Aug 26, 2026
@Veykril
Veykril added this pull request to the merge queue Aug 26, 2026
Merged via the queue into zed-industries:main with commit 4278ff3 Aug 26, 2026
35 checks passed
isomoon pushed a commit to isomoon/zed that referenced this pull request Aug 28, 2026
Upstream zed-industries#62743 fixed closing-punctuation wrapping inside is_word_char, which
covers both the LineWrapper and line_layout's shaped-text path -- the two fork
patches that guarded the break rule on the previous char are dropped as
superseded. They also cost path/URL wrapping: guarding on prev_ch suppressed
the '/' break opportunity upstream deliberately keeps, moving the boundaries
of 'aaa/bbbbbb/cccccc/dddddd' from 3/10/17 to mid-segment 7/14/21.

These tests pin all three behaviours against upstream's implementation.
playdohface pushed a commit to playdohface/zed that referenced this pull request Aug 29, 2026
…ed-industries#62743)

# Objective

`LineWrapper` treats every punctuation character as a break opportunity,
so a wrap can land right before `!`, `?`, `/`, `)`, `]`, `}`, a closing
quote or an ellipsis. Text such as `please fix this plz!`, `8.0/8.0`,
`cli/install`, `(see)` or `“quoted”` then wraps with the closing mark
orphaned at the start of the next line.

## Solution

Add the "UAX 14 LB13 rule" to `LineWrapper::is_word_char`, which is to
not break before `! ? / ) ] } " ” » …`

## Testing

Added unit tests and manually tested myself with a long paragraph in a
gpui app.

## 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 adheres to Zed's UI standards
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable (one
extra `matches!` per character in the wrap loop)

---

Release Notes:

- Fixed text wrapping so closing punctuation and slashes never begin a
wrapped line.

Co-authored-by: Lukas Wirth <lukas@zed.dev>
m-altaifi pushed a commit to m-altaifi/zed that referenced this pull request Sep 2, 2026
…ed-industries#62743)

# Objective

`LineWrapper` treats every punctuation character as a break opportunity,
so a wrap can land right before `!`, `?`, `/`, `)`, `]`, `}`, a closing
quote or an ellipsis. Text such as `please fix this plz!`, `8.0/8.0`,
`cli/install`, `(see)` or `“quoted”` then wraps with the closing mark
orphaned at the start of the next line.

## Solution

Add the "UAX 14 LB13 rule" to `LineWrapper::is_word_char`, which is to
not break before `! ? / ) ] } " ” » …`

## Testing

Added unit tests and manually tested myself with a long paragraph in a
gpui app.

## 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 adheres to Zed's UI standards
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable (one
extra `matches!` per character in the wrap loop)

---

Release Notes:

- Fixed text wrapping so closing punctuation and slashes never begin a
wrapped line.

Co-authored-by: Lukas Wirth <lukas@zed.dev>
yunxinx added a commit to yunxinx/zed that referenced this pull request Sep 2, 2026
- line_break 不再维护独立的 is_legacy_word_character,改为复用 LineWrapper::is_word_char,消除两份词表与 dead_code
- 上游 zed-industries#62743 的 ASCII 收尾标点(! ) ] } ")不在行首规则随之进入 UAX zed-industries#14 断行策略
- 补充收尾标点、开引号与路径分隔符的断行回归测试
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:editor Feedback for code editing, formatting, editor iterations, etc area:gpui GPUI rendering framework support cla-signed The user has signed the Contributor License Agreement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants