Update cosmic-text to 0.13

This commit is contained in:
Héctor Ramón Jiménez 2025-03-10 19:45:11 +01:00
parent bae25b74f6
commit 201245a85d
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
5 changed files with 97 additions and 87 deletions

View file

@ -178,10 +178,8 @@ impl editor::Editor for Editor {
.get(cursor.line)
.expect("Cursor line should be present");
let layout = line
.layout_opt()
.as_ref()
.expect("Line layout should be cached");
let layout =
line.layout_opt().expect("Line layout should be cached");
let mut lines = layout.iter().enumerate();
@ -706,11 +704,7 @@ fn highlight_line(
from: usize,
to: usize,
) -> impl Iterator<Item = (f32, f32)> + '_ {
let layout = line
.layout_opt()
.as_ref()
.map(Vec::as_slice)
.unwrap_or_default();
let layout = line.layout_opt().map(Vec::as_slice).unwrap_or_default();
layout.iter().map(move |visual_line| {
let start = visual_line
@ -761,9 +755,7 @@ fn visual_lines_offset(line: usize, buffer: &cosmic_text::Buffer) -> i32 {
let visual_lines_offset: usize = buffer.lines[start..]
.iter()
.take(end - start)
.map(|line| {
line.layout_opt().as_ref().map(Vec::len).unwrap_or_default()
})
.map(|line| line.layout_opt().map(Vec::len).unwrap_or_default())
.sum();
visual_lines_offset as i32 * if scroll.line < line { 1 } else { -1 }

View file

@ -156,6 +156,7 @@ impl core::text::Paragraph for Paragraph {
}),
text::to_attributes(text.font),
text::to_shaping(text.shaping),
None,
);
let min_bounds = text::measure(&buffer);