diff --git a/crates/engine/src/cmd/richclip.rs b/crates/engine/src/cmd/richclip.rs
index 063bd392..6e62b67d 100644
--- a/crates/engine/src/cmd/richclip.rs
+++ b/crates/engine/src/cmd/richclip.rs
@@ -42,28 +42,26 @@ pub fn body_to_html(body: &TextBody) -> String {
out
}
+/// The text without formatting, or "" (no HTML on the clipboard) when even that is too big: a
+/// cut-off prefix would paste as if it were the whole text.
fn plain_html(body: &TextBody) -> String {
let mut out = String::new();
for (i, p) in body.paragraphs.iter().enumerate() {
let prefix = if i > 0 { "
" } else { "
" };
if !push_if_fits(&mut out, prefix, 4) {
- break;
+ return String::new();
}
- let mut complete = true;
for r in &p.runs {
- if matches!(&r.kind, deckcraft_model::text::RunKind::Break) {
- complete = push_if_fits(&mut out, "
", 4);
+ let fits = if matches!(&r.kind, deckcraft_model::text::RunKind::Break) {
+ push_if_fits(&mut out, "
", 4)
} else {
- complete = push_escaped_bounded(&mut out, &r.text, 4);
- }
- if !complete {
- break;
+ push_escaped_bounded(&mut out, &r.text, 4)
+ };
+ if !fits {
+ return String::new();
}
}
out.push_str("