# editor: Preserve non-breaking whitespace during rewrap \(\#59893\) · gitcafe/zed

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

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

Visibility: public

Requested revision: 9dfdaa62b72a1afb45d33df0204db3945e686c8e

Requested commit: 9dfdaa62b72a1afb45d33df0204db3945e686c8e

Commit: 9dfdaa62b72a1afb45d33df0204db3945e686c8e

Tree: bfeb2c5191fcf6ce15f74164ed6abdabe8511dd6

Author: Aliaksandr Zhyburtovich

Committer: GitHub

## Message

```
editor: Preserve non-breaking whitespace during rewrap (#59893)

## Objective

Prevent rewrap from breaking at whitespace that Unicode classifies as
non-breaking.

The original approach, prompted by #59664, treated every non-ASCII
whitespace character as unbreakable. Unicode classifies `U+2009 THIN
SPACE` as breakable and `U+202F NARROW NO-BREAK SPACE` as its
non-breaking counterpart.

## Solution

- Treat `U+00A0 NO-BREAK SPACE`, `U+2007 FIGURE SPACE`, and `U+202F
NARROW NO-BREAK SPACE` as part of the surrounding word
- Keep thin spaces, em spaces, and other Unicode breaking spaces as
line-break opportunities
- Cover all three non-breaking whitespace variants in tokenizer and
wrapping tests

## Testing

- `cargo test -p editor rewrap::tests`

Release Notes:

- Fixed rewrap breaking lines at non-breaking spaces.

---------

Co-authored-by: Nathan Sobo <nathan@zed.dev>
```

## Parents

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

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