Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Remove non-wrapping settings from the language configuration (#18412)
Kirill Bulatovc83d00713858
diff --git a/assets/settings/default.json b/assets/settings/default.jsonindex cf0de6a5e7f..b3be17ad2ce 100644--- a/assets/settings/default.json+++ b/assets/settings/default.json@@ -535,17 +535,16 @@// How to soft-wrap long lines of text.// Possible values://- // 1. Do not soft wrap.- // "soft_wrap": "none",// 2. Prefer a single line generally, unless an overly long line is encountered.- // "soft_wrap": "prefer_line",+ // "soft_wrap": "none",+ // "soft_wrap": "prefer_line", // (deprecated, same as "none")// 3. Soft wrap lines that overflow the editor.// "soft_wrap": "editor_width",// 4. Soft wrap lines at the preferred line length.// "soft_wrap": "preferred_line_length",// 5. Soft wrap lines at the preferred line length or the editor width (whichever is smaller).// "soft_wrap": "bounded",- "soft_wrap": "prefer_line",+ "soft_wrap": "none",// The column at which to soft-wrap lines, for buffers where soft-wrap// is enabled."preferred_line_length": 80,diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rsindex 54d23a8219d..b7f825df9ee 100644--- a/crates/editor/src/editor.rs+++ b/crates/editor/src/editor.rs@@ -376,12 +376,20 @@ pub enum EditorMode {Full,}-#[derive(Clone, Debug)]+#[derive(Copy, Clone, Debug)]pub enum SoftWrap {+ /// Prefer not to wrap at all.+ ///+ /// Note: this is currently internal, as actually limited by [`crate::MAX_LINE_LEN`] until it wraps.+ /// The mode is used inside git diff hunks, where it's seems currently more useful to not wrap as much as possible.+ GitDiff,+ /// Prefer a single line generally, unless an overly long line is encountered.None,- PreferLine,+ /// Soft wrap lines that exceed the editor width.EditorWidth,+ /// Soft wrap lines at the preferred line length.Column(u32),+ /// Soft wrap line at the preferred line length or the editor width (whichever is smaller).Bounded(u32),}@@ -1837,7 +1845,7 @@ impl Editor {let blink_manager = cx.new_model(|cx| BlinkManager::new(CURSOR_BLINK_INTERVAL, cx));let soft_wrap_mode_override = matches!(mode, EditorMode::SingleLine { .. })- .then(|| language_settings::SoftWrap::PreferLine);+ .then(|| language_settings::SoftWrap::None);let mut project_subscriptions = Vec::new();if mode == EditorMode::Full {@@ -10898,8 +10906,9 @@ impl Editor {let settings = self.buffer.read(cx).settings_at(0, cx);let mode = self.soft_wrap_mode_override.unwrap_or(settings.soft_wrap);match mode {- language_settings::SoftWrap::None => SoftWrap::None,- language_settings::SoftWrap::PreferLine => SoftWrap::PreferLine,+ language_settings::SoftWrap::PreferLine | language_settings::SoftWrap::None => {+ SoftWrap::None+ }language_settings::SoftWrap::EditorWidth => SoftWrap::EditorWidth,language_settings::SoftWrap::PreferredLineLength => {SoftWrap::Column(settings.preferred_line_length)@@ -10947,9 +10956,10 @@ impl Editor {self.soft_wrap_mode_override.take();} else {let soft_wrap = match self.soft_wrap_mode(cx) {- SoftWrap::None | SoftWrap::PreferLine => language_settings::SoftWrap::EditorWidth,+ SoftWrap::GitDiff => return,+ SoftWrap::None => language_settings::SoftWrap::EditorWidth,SoftWrap::EditorWidth | SoftWrap::Column(_) | SoftWrap::Bounded(_) => {- language_settings::SoftWrap::PreferLine+ language_settings::SoftWrap::None}};self.soft_wrap_mode_override = Some(soft_wrap);diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rsindex 6f30062d47e..bad16b225f3 100644--- a/crates/editor/src/element.rs+++ b/crates/editor/src/element.rs@@ -4994,10 +4994,8 @@ impl Element for EditorElement {snapshot} else {let wrap_width = match editor.soft_wrap_mode(cx) {- SoftWrap::None => None,- SoftWrap::PreferLine => {- Some((MAX_LINE_LEN / 2) as f32 * em_advance)- }+ SoftWrap::GitDiff => None,+ SoftWrap::None => Some((MAX_LINE_LEN / 2) as f32 * em_advance),SoftWrap::EditorWidth => Some(editor_width),SoftWrap::Column(column) => Some(column as f32 * em_advance),SoftWrap::Bounded(column) => {diff --git a/crates/language/src/language_settings.rs b/crates/language/src/language_settings.rsindex f830c5f25c3..2f1a7be2bf4 100644--- a/crates/language/src/language_settings.rs+++ b/crates/language/src/language_settings.rs@@ -379,15 +379,16 @@ pub struct FeaturesContent {#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, Eq, JsonSchema)]#[serde(rename_all = "snake_case")]pub enum SoftWrap {- /// Do not soft wrap.+ /// Prefer a single line generally, unless an overly long line is encountered.None,+ /// Deprecated: use None instead. Left to avoid breakin existing users' configs./// Prefer a single line generally, unless an overly long line is encountered.PreferLine,- /// Soft wrap lines that exceed the editor width+ /// Soft wrap lines that exceed the editor width.EditorWidth,- /// Soft wrap lines at the preferred line length+ /// Soft wrap lines at the preferred line length.PreferredLineLength,- /// Soft wrap line at the preferred line length or the editor width (whichever is smaller)+ /// Soft wrap line at the preferred line length or the editor width (whichever is smaller).Bounded,}diff --git a/docs/src/configuring-zed.md b/docs/src/configuring-zed.mdindex 7837044a60a..18d66708ad7 100644--- a/docs/src/configuring-zed.md+++ b/docs/src/configuring-zed.md@@ -1357,12 +1357,12 @@ Or to set a `socks5` proxy:- Description: Whether or not to automatically wrap lines of text to fit editor / preferred width.- Setting: `soft_wrap`-- Default: `prefer_line`+- Default: `none`**Options**-1. `none` to stop the soft-wrapping-2. `prefer_line` to avoid wrapping generally, unless the line is too long+1. `none` to avoid wrapping generally, unless the line is too long+2. `prefer_line` (deprecated, same as `none`)3. `editor_width` to wrap lines that overflow the editor width4. `preferred_line_length` to wrap lines that overflow `preferred_line_length` config value