diff options
Diffstat (limited to 'helix-tui')
-rw-r--r-- | helix-tui/Cargo.toml | 1 | ||||
-rw-r--r-- | helix-tui/src/text.rs | 3 | ||||
-rw-r--r-- | helix-tui/src/widgets/reflow.rs | 9 |
3 files changed, 8 insertions, 5 deletions
diff --git a/helix-tui/Cargo.toml b/helix-tui/Cargo.toml index 89fa755d..30e2374d 100644 --- a/helix-tui/Cargo.toml +++ b/helix-tui/Cargo.toml @@ -22,3 +22,4 @@ unicode-segmentation = "1.2" unicode-width = "0.1" crossterm = { version = "0.20", optional = true } serde = { version = "1", "optional" = true, features = ["derive"]} +helix-core = { version = "0.2", path = "../helix-core" } diff --git a/helix-tui/src/text.rs b/helix-tui/src/text.rs index c671e918..b23bfd81 100644 --- a/helix-tui/src/text.rs +++ b/helix-tui/src/text.rs @@ -47,6 +47,7 @@ //! ]); //! ``` use crate::style::Style; +use helix_core::line_ending::str_is_line_ending; use std::borrow::Cow; use unicode_segmentation::UnicodeSegmentation; use unicode_width::UnicodeWidthStr; @@ -177,7 +178,7 @@ impl<'a> Span<'a> { symbol: g, style: base_style.patch(self.style), }) - .filter(|s| s.symbol != "\n") + .filter(|s| !str_is_line_ending(s.symbol)) } } diff --git a/helix-tui/src/widgets/reflow.rs b/helix-tui/src/widgets/reflow.rs index 94ff7330..ae561a4f 100644 --- a/helix-tui/src/widgets/reflow.rs +++ b/helix-tui/src/widgets/reflow.rs @@ -1,4 +1,5 @@ use crate::text::StyledGrapheme; +use helix_core::line_ending::str_is_line_ending; use unicode_segmentation::UnicodeSegmentation; use unicode_width::UnicodeWidthStr; @@ -62,13 +63,13 @@ impl<'a, 'b> LineComposer<'a> for WordWrapper<'a, 'b> { // Ignore characters wider that the total max width. if symbol.width() as u16 > self.max_line_width // Skip leading whitespace when trim is enabled. - || self.trim && symbol_whitespace && symbol != "\n" && current_line_width == 0 + || self.trim && symbol_whitespace && !str_is_line_ending(symbol) && current_line_width == 0 { continue; } // Break on newline and discard it. - if symbol == "\n" { + if str_is_line_ending(symbol) { if prev_whitespace { current_line_width = width_to_last_word_end; self.current_line.truncate(symbols_to_last_word_end); @@ -170,7 +171,7 @@ impl<'a, 'b> LineComposer<'a> for LineTruncator<'a, 'b> { } // Break on newline and discard it. - if symbol == "\n" { + if str_is_line_ending(symbol) { break; } @@ -199,7 +200,7 @@ impl<'a, 'b> LineComposer<'a> for LineTruncator<'a, 'b> { if skip_rest { for StyledGrapheme { symbol, .. } in &mut self.symbols { - if symbol == "\n" { + if str_is_line_ending(symbol) { break; } } |