# editor: Improve rewrap to respect indent and prefix boundaries \(\#33566\) · gitcafe/zed

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

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

Visibility: public

Requested revision: bbf16bda75587626cc1e2bb959e714d817aeffec

Requested commit: bbf16bda75587626cc1e2bb959e714d817aeffec

Commit: bbf16bda75587626cc1e2bb959e714d817aeffec

Tree: 103ee18fc54ea928a10cffaf9f26dfca94135fcd

Author: Smit Barmase

Committer: GitHub

## Message

````
editor: Improve rewrap to respect indent and prefix boundaries (#33566)

1. Fixes bug where this would not rewrap:

```rs
// This is the first long comment block to be wrapped.
fn my_func(a: u32);
// This is the second long comment block to be wrapped.
```
2. Comment prefix boundaries (Notice now they don't merge between
different comment prefix):

Initial text:
```rs
// A regular long long comment to be wrapped.
// A second regular long comment to be wrapped.
/// A documentation long comment to be wrapped.
```
Upon rewrap:
```rs
// A regular long long comment to be
// wrapped. A second regular long
// comment to be wrapped.
/// A documentation long comment to be
/// wrapped.
```
3. Indent boundaries (Notice now they don't merge between different
indentation):

Initial text:
```rs
fn foo() {
      // This is a long comment at the base indent.
      // This is a long comment at the base indent.
                 // This is a long comment at the next indent.
                 // This is a long comment at the next indent.
      // This is a long comment at the base indent.
}
```
Upon rewrap:
```rs
fn foo() {
      // This is a long comment at the base
      // indent. This is a long comment at the
      // base indent.
                 // This is a long comment at the 
                 // next indent. This is a long 
                 // comment at the next indent.
      // This is a long comment at the base
      // indent.
}
```

Release Notes:

- Fixed an issue where rewrap would not work with selection when two
comment blocks are separated with line of code.
- Improved rewrap to respect changes in indentation or comment prefix
(e.g. `//` vs `///`) as boundaries so that it doesn't merge them into
one mangled text.
````

## Parents

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

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