summaryrefslogtreecommitdiff
path: root/helix-tui/src/widgets/reflow.rs
diff options
context:
space:
mode:
authorNathan Vegdahl2021-06-20 22:09:10 +0000
committerNathan Vegdahl2021-06-20 22:33:02 +0000
commit4efd6713c5b30b33c497a1f85b77a7b0a7fd17e0 (patch)
tree7661f09f2279a3f9ae6a8f76770a69fd08f95981 /helix-tui/src/widgets/reflow.rs
parent5d22e3c4e574eb24260966de7f20f582e6184e24 (diff)
Work on moving code over to LineEnding instead of assuming '\n'.
Also some general cleanup and some minor fixes along the way.
Diffstat (limited to 'helix-tui/src/widgets/reflow.rs')
-rw-r--r--helix-tui/src/widgets/reflow.rs9
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;
}
}