From b877f873dfb09dbb990fa46aea6b03028252c6f5 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Fri, 15 Dec 2023 10:02:32 -0700 Subject: [PATCH] BufferLine: remove wrap from struct, as wrap is passed to layout --- src/buffer_line.rs | 24 +----------------------- src/edit/syntect.rs | 3 +-- 2 files changed, 2 insertions(+), 25 deletions(-) diff --git a/src/buffer_line.rs b/src/buffer_line.rs index 86970d1..7d8e031 100644 --- a/src/buffer_line.rs +++ b/src/buffer_line.rs @@ -9,7 +9,6 @@ pub struct BufferLine { //TODO: make this not pub(crate) text: String, attrs_list: AttrsList, - wrap: Wrap, align: Option, shape_opt: Option, layout_opt: Option>, @@ -24,7 +23,6 @@ impl BufferLine { Self { text: text.into(), attrs_list, - wrap: Wrap::Word, align: None, shape_opt: None, layout_opt: None, @@ -78,25 +76,6 @@ impl BufferLine { } } - /// Get wrapping setting (wrap by characters/words or no wrapping) - pub fn wrap(&self) -> Wrap { - self.wrap - } - - /// Set wrapping setting (wrap by characters/words or no wrapping) - /// - /// Will reset shape and layout if it differs from current wrapping setting. - /// Returns true if the line was reset - pub fn set_wrap(&mut self, wrap: Wrap) -> bool { - if wrap != self.wrap { - self.wrap = wrap; - self.reset_layout(); - true - } else { - false - } - } - /// Get the Text alignment pub fn align(&self) -> Option { self.align @@ -146,7 +125,7 @@ impl BufferLine { self.reset(); let mut new = Self::new(text, attrs_list, self.shaping); - new.wrap = self.wrap; + new.align = self.align; new } @@ -223,7 +202,6 @@ impl BufferLine { wrap: Wrap, ) -> &[LayoutLine] { if self.layout_opt.is_none() { - self.wrap = wrap; let align = self.align; let shape = self.shape_in_buffer(scratch, font_system); let mut layout = Vec::with_capacity(1); diff --git a/src/edit/syntect.rs b/src/edit/syntect.rs index 5abfadd..00da3bf 100644 --- a/src/edit/syntect.rs +++ b/src/edit/syntect.rs @@ -9,7 +9,7 @@ use syntect::parsing::{ParseState, ScopeStack, SyntaxReference, SyntaxSet}; use crate::{ Action, AttrsList, BorrowedWithFontSystem, Buffer, Change, Color, Cursor, Edit, Editor, - FontSystem, Selection, Shaping, Style, Weight, Wrap, + FontSystem, Selection, Shaping, Style, Weight, }; pub use syntect::highlighting::Theme as SyntaxTheme; @@ -283,7 +283,6 @@ impl<'a> Edit for SyntaxEditor<'a> { // Update line attributes. This operation only resets if the line changes line.set_attrs_list(attrs_list); - line.set_wrap(Wrap::Word); // Perform shaping and layout of this line in order to count if we have reached scroll match buffer.line_layout(font_system, line_i) {