Skip to content

Commit f406701

Browse files
committed
Add comment and check for newline before multiline layout
1 parent 25da822 commit f406701

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

crates/epaint/src/text/fonts.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,11 @@ impl GalleyCache {
762762
cached.galley.clone()
763763
}
764764
std::collections::hash_map::Entry::Vacant(entry) => {
765-
if job.break_on_newline {
765+
// If the text contains newlines that will always break into a new row then
766+
// we can easily lay out all the lines separately and then merge the `Galley`s.
767+
// This allows individual lines to be cached separately which means small
768+
// modifications to the source text will only cause impacted lines to be laid out again.
769+
if job.break_on_newline && job.text.contains('\n') {
766770
let galley = self.layout_multiline(fonts, job);
767771
let galley = Arc::new(galley);
768772
self.cache.insert(

0 commit comments

Comments
 (0)