# Fix soft_wrap setting not applying to buffers starting with a different language \(\#25880\) · gitcafe/zed

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

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

Visibility: public

Requested revision: 0ec15d6b02f4c0775c11e0f5dc3be6959ce7a75a

Requested commit: 0ec15d6b02f4c0775c11e0f5dc3be6959ce7a75a

Commit: 0ec15d6b02f4c0775c11e0f5dc3be6959ce7a75a

Tree: 0a421a9a271214a06f1801e5a831e396f9de1735

Author: Alex Ozer

Committer: GitHub

## Message

````
Fix soft_wrap setting not applying to buffers starting with a different language (#25880)

Closes #22999 
# Problem

Currently, the default soft wrap mode of an editor is determined by
reading the language-specific settings of the language _at offset zero_
in the editor's (multi)buffer. While this provides a way to pick a
single soft wrap mode for a multi-language multibuffer, it's a bad
choice for a single-buffer multibuffer that begins with a different
embedded language. For example, Markdown with frontmatter:

```markdown
---
my_front_matter
---

# Hello World
```

Setting this in config:

```json
  "languages": {
    "Markdown": { "soft_wrap": "bounded" }
  },
```

Will not soft wrap the Markdown file as the language at offset zero is
YAML.

# Solution

Instead of using the language at offset zero, use the language of the
first buffer in the multibuffer (the buffer at offset zero). This gives
better behavior for single-buffer editors, and a similar default for
multi-language multibuffers as before.

# Testing

All existing `editor` crate tests pass, but I would appreciate any
guidance for where best to add additional testing.

Release Notes:

- Fixed soft_wrap setting not applying to buffers starting with a
different language

---------

Co-authored-by: Kirill Bulatov <kirill@zed.dev>
````

## Parents

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

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