diff --git a/book/src/configuration.md b/book/src/configuration.md index cb3283e08ed74..0e1440936af7c 100644 --- a/book/src/configuration.md +++ b/book/src/configuration.md @@ -264,9 +264,10 @@ Options for soft wrapping lines that exceed the view width | Key | Description | Default | | --- | --- | --- | | `enable` | Whether soft wrapping is enabled. | `false` | -| `max-wrap` | Maximum free space left at the end of the line. | `20` | +| `max-wrap` | Maximum free space left at the end of the line. | `20` | | `max-indent-retain` | Maximum indentation to carry over when soft wrapping a line. | `40` | | `wrap-indicator` | Text inserted before soft wrapped lines. | `↪ ` | +| | Highlighted with `ui.virtual.wrap`. | | Example: diff --git a/helix-view/src/document.rs b/helix-view/src/document.rs index 5fcbf04928de7..0aaa3cb917b5f 100644 --- a/helix-view/src/document.rs +++ b/helix-view/src/document.rs @@ -1210,7 +1210,13 @@ impl Document { } } - pub fn text_format(&self, viewport_width: u16, theme: Option<&Theme>) -> TextFormat { + pub fn text_format(&self, mut viewport_width: u16, theme: Option<&Theme>) -> TextFormat { + if let Some(max_line_len) = self + .language_config() + .and_then(|config| config.max_line_length) + { + viewport_width = viewport_width.min(max_line_len as u16) + } let config = self.config.load(); let soft_wrap = &config.soft_wrap; let tab_width = self.tab_width() as u16; @@ -1224,7 +1230,7 @@ impl Document { viewport_width, wrap_indicator: soft_wrap.wrap_indicator.clone().into_boxed_str(), wrap_indicator_highlight: theme - .and_then(|theme| theme.find_scope_index_exact("ui.virtual.whitespace")) + .and_then(|theme| theme.find_scope_index("ui.virtual.wrap")) .map(Highlight), } }