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>
This commit is contained in:
parent
909de2ca6f
commit
0ec15d6b02
4 changed files with 64 additions and 25 deletions
|
@ -4685,7 +4685,7 @@ impl EditorElement {
|
|||
.read(cx)
|
||||
.buffer
|
||||
.read(cx)
|
||||
.settings_at(0, cx)
|
||||
.language_settings(cx)
|
||||
.show_whitespaces;
|
||||
|
||||
for (ix, line_with_invisibles) in layout.position_map.line_layouts.iter().enumerate() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue