diff options
author | Blaž Hrastnik | 2021-06-22 02:09:19 +0000 |
---|---|---|
committer | GitHub | 2021-06-22 02:09:19 +0000 |
commit | a70de6e980ec58cabf58c33e8b91bfafbea312eb (patch) | |
tree | 476c07b84ee3f399eb55c8b549641a59eedc4e1c /helix-tui/src/widgets/reflow.rs | |
parent | c704970fd71a1a29ef8397ff2ab9e12c5b780a81 (diff) | |
parent | f2954fa153ccb6b147d8d38020341a2f1b0b6df2 (diff) |
Merge pull request #224 from helix-editor/line_ending_detection
Line ending detection
Diffstat (limited to 'helix-tui/src/widgets/reflow.rs')
-rw-r--r-- | helix-tui/src/widgets/reflow.rs | 9 |
1 files changed, 5 insertions, 4 deletions
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; } } |