# Add \`allow_rewrap\` setting to control \`editor::Rewrap\` behavior for a given language \(\#25173\) · gitcafe/zed

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

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

Visibility: public

Requested revision: d17c6b392ec3b89cbaffdf83a890587c99e6b32d

Requested commit: d17c6b392ec3b89cbaffdf83a890587c99e6b32d

Commit: d17c6b392ec3b89cbaffdf83a890587c99e6b32d

Tree: b42b77c4afff04e44c30a73ee1ed209c43ff7aeb

Author: Marshall Bowers

Committer: GitHub

## Message

````
Add `allow_rewrap` setting to control `editor::Rewrap` behavior for a given language (#25173)

This PR adds a new `allow_rewrap` setting to control how
`editor::Rewrap` behaves for a given language.

This is a language setting, so it can either be configured globally or
within the context of an individual language.

For example:

```json
{
  "allow_rewrap": "in_selections",
  "languages": {
    "Typst": {
      "allow_rewrap": "anywhere"
    }
  }
}
```

There are three different values:

- `in_comment`: Only perform rewrapping within comments.
- `in_selections`: Only perform rewrapping within the current
selection(s).
- `anywhere`: Allow rewrapping anywhere.

The global default is `in_comment`, as it is the most conservative
option and allows rewrapping comments without risking breaking other
syntax.

The `Markdown` and `Plain Text` languages default to `anywhere`, which
mirrors the previous behavior for those language that was hard-coded
into the rewrap implementation.

This setting does not have any effect in Vim mode, as Vim mode already
allowed rewrapping anywhere.

Closes https://github.com/zed-industries/zed/issues/24242.

Release Notes:

- Added an `allow_rewrap` setting to control the `editor::Rewrap`
behavior for a given language.
````

## Parents

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

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