BufferLine: remove wrap from struct, as wrap is passed to layout

This commit is contained in:
Jeremy Soller 2023-12-15 10:02:32 -07:00
parent 816ea4fae7
commit b877f873df
2 changed files with 2 additions and 25 deletions

View file

@ -9,7 +9,6 @@ pub struct BufferLine {
//TODO: make this not pub(crate)
text: String,
attrs_list: AttrsList,
wrap: Wrap,
align: Option<Align>,
shape_opt: Option<ShapeLine>,
layout_opt: Option<Vec<LayoutLine>>,
@ -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<Align> {
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);

View file

@ -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) {