Skip to content

Commit 985cadb

Browse files
chore: code review
1 parent 27d1dd1 commit 985cadb

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

editor/src/messages/tool/tool_messages/text_tool.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,7 @@ impl TextToolData {
459459
}
460460

461461
self.layer = layer;
462+
self.is_lorem_ipsum = false; // Editing an existing layer — discard any lorem ipsum state
462463
if self.load_layer_text_node(document).is_some() {
463464
responses.add(DocumentMessage::AddTransaction);
464465

@@ -1095,6 +1096,9 @@ fn get_lorem_ipsum_text(constraint_size: Option<DVec2>, font: &Font, font_cache:
10951096
let average_advance = if sample_width > 0. { sample_width / SAMPLE_TEXT.len() as f64 } else { font_size * 0.45 };
10961097

10971098
let line_height = font_size * line_height_ratio;
1099+
if line_height <= 0. {
1100+
return LOREM_IPSUM.split_whitespace().take(LOREM_IPSUM_DEFAULT_WORD_COUNT).collect::<Vec<_>>().join(" ");
1101+
}
10981102
let chars_per_line = (size.x / average_advance).floor().max(1.) as usize;
10991103
let lines = (size.y / line_height).floor().max(1.) as usize;
11001104

0 commit comments

Comments
 (0)