on master help sign in
Revert "Fix #6605: Remove soft-wrap.enable option wrapping. (#6656)"

This caused a bug that would ignore the global config. This reverts commit af88a3c15cc4ddbb1e2f2ea6492868ffb8aba40b.

commit58e457a4e1037caf43c17dea93c5321c1ae74103 authorBlaž Hrastnik <blaz@mxxn.io> dateSat 8 Apr 2023, 21:50 (4 years ago) parent25858ec
2 files changed+6−3
helix-core/src/syntax.rs+3−1 helix-view/src/document.rs+3−2
helix-core/src/syntax.rs+3−1
@@ -555,7 +555,9 @@ impl LanguageConfiguration {
555555#[serde(default, rename_all = "kebab-case", deny_unknown_fields)]
556556pub struct SoftWrap {
557557 /// Soft wrap lines that exceed viewport width. Default to off
558− pub enable: bool,
558+ // NOTE: Option on purpose because the struct is shared between language config and global config.
559+ // By default the option is None so that the language config falls back to the global config unless explicitly set.
560+ pub enable: Option<bool>,
559561 /// Maximum space left free at the end of the line.
560562 /// This space is used to wrap text at word boundaries. If that is not possible within this limit
561563 /// the word is simply split at the end of the line.
helix-view/src/document.rs+3−2
@@ -1444,8 +1444,9 @@ impl Document {
14441444 .as_ref()
14451445 .and_then(|config| config.soft_wrap.as_ref());
14461446 let enable_soft_wrap = language_soft_wrap
1447− .map(|soft_wrap| soft_wrap.enable)
1448− .unwrap_or_else(|| editor_soft_wrap.enable);
1447+ .and_then(|soft_wrap| soft_wrap.enable)
1448+ .or(editor_soft_wrap.enable)
1449+ .unwrap_or(false);
14491450 let max_wrap = language_soft_wrap
14501451 .and_then(|soft_wrap| soft_wrap.max_wrap)
14511452 .or(config.soft_wrap.max_wrap)