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
|
@ -160,7 +160,7 @@ impl Vim {
|
|||
.buffer()
|
||||
.read(cx)
|
||||
.snapshot(cx)
|
||||
.settings_at(cursor_offset, cx)
|
||||
.language_settings_at(cursor_offset, cx)
|
||||
.auto_indent_on_paste
|
||||
{
|
||||
editor.edit_with_block_indent(edits, original_start_columns, cx);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue