Remove min_bounds field in graphics::text::Editor

This commit is contained in:
Héctor Ramón Jiménez 2023-09-14 18:58:52 +02:00
parent c7d02e24e6
commit 3afac11784
No known key found for this signature in database
GPG key ID: 7CC46565708259A7

View file

@ -15,7 +15,6 @@ struct Internal {
editor: cosmic_text::Editor, editor: cosmic_text::Editor,
font: Font, font: Font,
bounds: Size, bounds: Size,
min_bounds: Size,
version: text::Version, version: text::Version,
} }
@ -426,14 +425,10 @@ impl editor::Editor for Editor {
let mut font_system = let mut font_system =
text::font_system().write().expect("Write font system"); text::font_system().write().expect("Write font system");
let mut changed = false;
if font_system.version() != internal.version { if font_system.version() != internal.version {
for line in internal.editor.buffer_mut().lines.iter_mut() { for line in internal.editor.buffer_mut().lines.iter_mut() {
line.reset(); line.reset();
} }
changed = true;
} }
if new_font != internal.font { if new_font != internal.font {
@ -442,8 +437,6 @@ impl editor::Editor for Editor {
text::to_attributes(new_font), text::to_attributes(new_font),
)); ));
} }
changed = true;
} }
let metrics = internal.editor.buffer().metrics(); let metrics = internal.editor.buffer().metrics();
@ -456,8 +449,6 @@ impl editor::Editor for Editor {
font_system.raw(), font_system.raw(),
cosmic_text::Metrics::new(new_size.0, new_line_height.0), cosmic_text::Metrics::new(new_size.0, new_line_height.0),
); );
changed = true;
} }
if new_bounds != internal.bounds { if new_bounds != internal.bounds {
@ -468,11 +459,6 @@ impl editor::Editor for Editor {
); );
internal.bounds = new_bounds; internal.bounds = new_bounds;
changed = true;
}
if changed {
internal.min_bounds = text::measure(internal.editor.buffer());
} }
self.0 = Some(Arc::new(internal)); self.0 = Some(Arc::new(internal));
@ -489,7 +475,6 @@ impl PartialEq for Internal {
fn eq(&self, other: &Self) -> bool { fn eq(&self, other: &Self) -> bool {
self.font == other.font self.font == other.font
&& self.bounds == other.bounds && self.bounds == other.bounds
&& self.min_bounds == other.min_bounds
&& self.editor.buffer().metrics() == other.editor.buffer().metrics() && self.editor.buffer().metrics() == other.editor.buffer().metrics()
} }
} }
@ -505,7 +490,6 @@ impl Default for Internal {
)), )),
font: Font::default(), font: Font::default(),
bounds: Size::ZERO, bounds: Size::ZERO,
min_bounds: Size::ZERO,
version: text::Version::default(), version: text::Version::default(),
} }
} }
@ -516,7 +500,6 @@ impl fmt::Debug for Internal {
f.debug_struct("Internal") f.debug_struct("Internal")
.field("font", &self.font) .field("font", &self.font)
.field("bounds", &self.bounds) .field("bounds", &self.bounds)
.field("min_bounds", &self.min_bounds)
.finish() .finish()
} }
} }