summaryrefslogtreecommitdiffstats
path: root/graphics
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2023-09-13 16:31:56 +0200
committerLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2023-09-13 16:31:56 +0200
commitf14ef7a6069cf45ae11261d7d20df6a5d7870dde (patch)
tree019e4c9fdc25e4095e134585577e355b9b0a33e5 /graphics
parentf4c51a96d50953d5fb6e9eb62194f226e2cbfd3c (diff)
downloadiced-f14ef7a6069cf45ae11261d7d20df6a5d7870dde.tar.gz
iced-f14ef7a6069cf45ae11261d7d20df6a5d7870dde.tar.bz2
iced-f14ef7a6069cf45ae11261d7d20df6a5d7870dde.zip
Fix `clippy` lints
Diffstat (limited to 'graphics')
-rw-r--r--graphics/src/text/editor.rs27
1 files changed, 18 insertions, 9 deletions
diff --git a/graphics/src/text/editor.rs b/graphics/src/text/editor.rs
index 747f3a80..d31ea390 100644
--- a/graphics/src/text/editor.rs
+++ b/graphics/src/text/editor.rs
@@ -25,7 +25,7 @@ impl Editor {
}
pub fn buffer(&self) -> &cosmic_text::Buffer {
- &self.internal().editor.buffer()
+ self.internal().editor.buffer()
}
pub fn downgrade(&self) -> Weak {
@@ -53,11 +53,11 @@ impl editor::Editor for Editor {
line_height: 1.0,
});
+ let mut font_system =
+ text::font_system().write().expect("Write font system");
+
buffer.set_text(
- text::font_system()
- .write()
- .expect("Write font system")
- .raw(),
+ font_system.raw(),
text,
cosmic_text::Attrs::new(),
cosmic_text::Shaping::Advanced,
@@ -65,6 +65,7 @@ impl editor::Editor for Editor {
Editor(Some(Arc::new(Internal {
editor: cosmic_text::Editor::new(buffer),
+ version: font_system.version(),
..Default::default()
})))
}
@@ -347,6 +348,14 @@ impl editor::Editor for Editor {
let mut changed = false;
+ if font_system.version() != internal.version {
+ for line in internal.editor.buffer_mut().lines.iter_mut() {
+ line.reset();
+ }
+
+ changed = true;
+ }
+
if new_font != internal.font {
for line in internal.editor.buffer_mut().lines.iter_mut() {
let _ = line.set_attrs_list(cosmic_text::AttrsList::new(
@@ -383,7 +392,7 @@ impl editor::Editor for Editor {
}
if changed {
- internal.min_bounds = text::measure(&internal.editor.buffer());
+ internal.min_bounds = text::measure(internal.editor.buffer());
}
self.0 = Some(Arc::new(internal));
@@ -453,11 +462,11 @@ impl PartialEq for Weak {
}
}
-fn highlight_line<'a>(
- line: &'a cosmic_text::BufferLine,
+fn highlight_line(
+ line: &cosmic_text::BufferLine,
from: usize,
to: usize,
-) -> impl Iterator<Item = (f32, f32)> + 'a {
+) -> impl Iterator<Item = (f32, f32)> + '_ {
let layout = line
.layout_opt()
.as_ref()