feat(chat): clicking a quote jumps to the quoted message, its links are plain text
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@@ -119,7 +119,7 @@ mod tests {
119
119
&outgoing,
120
120
Delivery::Sending,
121
121
);
122
assert!(matches!(row.blocks.first(), Some(Block::Reply(_))));
122
assert!(matches!(row.blocks.first(), Some(Block::Reply { .. })));
123
123
assert_eq!(row.blocks.len(), 2);
124
124
}
125
125
}
@@ -119,7 +119,7 @@ mod tests {119
&outgoing,119
&outgoing,120
Delivery::Sending,120
Delivery::Sending,121
);121
);122
assert!(matches!(row.blocks.first(), Some(Block::Reply(_))));122
assert!(matches!(row.blocks.first(), Some(Block::Reply { .. })));123
assert_eq!(row.blocks.len(), 2);123
assert_eq!(row.blocks.len(), 2);124
}124
}125
}125
}@@ -174,7 +174,10 @@ pub enum Block {
174
174
language: Option<String>,
175
175
code: String,
176
176
},
177
Reply(Vec<Block>),
177
Reply {
178
message_id: Option<String>,
179
children: Vec<Block>,
180
},
178
181
Quote(Vec<Block>),
179
182
List {
180
183
ordered: bool,
@@ -230,7 +233,7 @@ impl Block {
230
233
.join("\n"),
231
234
),
232
235
Block::Quote(children) => Some(join(children)),
233
Block::Reply(_) | Block::Rule | Block::Image { .. } => None,
236
Block::Reply { .. } | Block::Rule | Block::Image { .. } => None,
234
237
}
235
238
}
236
239
@@ -241,7 +244,7 @@ impl Block {
241
244
Block::List { items, .. } => items.first()?.iter().find_map(Block::first_line),
242
245
Block::Table { rows, .. } => Some(rows.first()?.first()?.plain_text()),
243
246
Block::Quote(children) => children.iter().find_map(Block::first_line),
244
Block::Reply(_) | Block::Rule | Block::Image { .. } => None,
247
Block::Reply { .. } | Block::Rule | Block::Image { .. } => None,
245
248
}
246
249
}
247
250
@@ -254,6 +257,22 @@ impl Block {
254
257
}
255
258
}
256
259
260
fn unlink(blocks: &mut [Block]) {
261
for block in blocks {
262
match block {
263
Block::Paragraph(inline) | Block::Heading { inline, .. } => {
264
for segment in &mut inline.segments {
265
segment.link = None;
266
segment.style.link = false;
267
}
268
}
269
Block::Reply { children, .. } | Block::Quote(children) => unlink(children),
270
Block::List { items, .. } => items.iter_mut().for_each(|item| unlink(item)),
271
_ => {}
272
}
273
}
274
}
275
257
276
pub fn strip_image_placeholders(blocks: Vec<Block>) -> Vec<Block> {
258
277
blocks
259
278
.into_iter()
@@ -262,9 +281,15 @@ pub fn strip_image_placeholders(blocks: Vec<Block>) -> Vec<Block> {
262
281
let stripped = inline.without(IMAGE_PLACEHOLDER);
263
282
(!stripped.is_blank()).then_some(Block::Paragraph(stripped))
264
283
}
265
Block::Reply(children) => {
284
Block::Reply {
285
message_id,
286
children,
287
} => {
266
288
let children = strip_image_placeholders(children);
267
(!children.is_empty()).then_some(Block::Reply(children))
289
(!children.is_empty()).then_some(Block::Reply {
290
message_id,
291
children,
292
})
268
293
}
269
294
Block::Quote(children) => {
270
295
let children = strip_image_placeholders(children);
@@ -307,16 +332,27 @@ fn layout_blocks_with(spans: &[Span], split_images: bool) -> Vec<Block> {
307
332
code: code.trim_end_matches('\n').to_owned(),
308
333
});
309
334
}
310
Span::Quote(children) | Span::BlockQuote(children) => {
335
Span::Quote {
336
message_id,
337
children,
338
} => {
311
339
flush(&mut current, &mut blocks, Block::Paragraph);
312
let inner = layout_blocks_with(children, false);
340
let mut inner = layout_blocks_with(children, false);
341
unlink(&mut inner);
313
342
if !inner.is_empty() {
314
blocks.push(match span {
315
Span::Quote(_) => Block::Reply(inner),
316
_ => Block::Quote(inner),
343
blocks.push(Block::Reply {
344
message_id: message_id.clone(),
345
children: inner,
317
346
});
318
347
}
319
348
}
349
Span::BlockQuote(children) => {
350
flush(&mut current, &mut blocks, Block::Paragraph);
351
let inner = layout_blocks_with(children, false);
352
if !inner.is_empty() {
353
blocks.push(Block::Quote(inner));
354
}
355
}
320
356
Span::List {
321
357
ordered,
322
358
start,
@@ -566,7 +602,7 @@ fn append_inline(spans: &[Span], style: StyleFlags, link: Option<&str>, out: &mu
566
602
);
567
603
}
568
604
Span::LineBreak | Span::Rule => out.push("\n", style, link),
569
Span::Quote(children) | Span::BlockQuote(children) => {
605
Span::Quote { children, .. } | Span::BlockQuote(children) => {
570
606
append_inline(children, style, link, out);
571
607
out.push("\n", style, link);
572
608
}
@@ -828,7 +864,7 @@ mod tests {
828
864
],
829
865
],
830
866
},
831
Span::Quote(vec![text("quoted")]),
867
Span::Quote { message_id: Some("m1".into()), children: vec![text("quoted")] },
832
868
]);
833
869
assert_eq!(
834
870
blocks,
@@ -848,7 +884,10 @@ mod tests {
848
884
],
849
885
],
850
886
},
851
Block::Reply(vec![Block::Paragraph(Inline::plain("quoted"))]),
887
Block::Reply {
888
message_id: Some("m1".into()),
889
children: vec![Block::Paragraph(Inline::plain("quoted"))]
890
},
852
891
]
853
892
);
854
893
}
@@ -174,7 +174,10 @@ pub enum Block {174
language: Option<String>,174
language: Option<String>,175
code: String,175
code: String,176
},176
},177
Reply(Vec<Block>),177
Reply {178
message_id: Option<String>,179
children: Vec<Block>,180
},178
Quote(Vec<Block>),181
Quote(Vec<Block>),179
List {182
List {180
ordered: bool,183
ordered: bool,@@ -230,7 +233,7 @@ impl Block {230
.join("\n"),233
.join("\n"),231
),234
),232
Block::Quote(children) => Some(join(children)),235
Block::Quote(children) => Some(join(children)),233
Block::Reply(_) | Block::Rule | Block::Image { .. } => None,236
Block::Reply { .. } | Block::Rule | Block::Image { .. } => None,234
}237
}235
}238
}236
239
@@ -241,7 +244,7 @@ impl Block {241
Block::List { items, .. } => items.first()?.iter().find_map(Block::first_line),244
Block::List { items, .. } => items.first()?.iter().find_map(Block::first_line),242
Block::Table { rows, .. } => Some(rows.first()?.first()?.plain_text()),245
Block::Table { rows, .. } => Some(rows.first()?.first()?.plain_text()),243
Block::Quote(children) => children.iter().find_map(Block::first_line),246
Block::Quote(children) => children.iter().find_map(Block::first_line),244
Block::Reply(_) | Block::Rule | Block::Image { .. } => None,247
Block::Reply { .. } | Block::Rule | Block::Image { .. } => None,245
}248
}246
}249
}247
250
@@ -254,6 +257,22 @@ impl Block {254
}257
}255
}258
}256
259
260
fn unlink(blocks: &mut [Block]) {261
for block in blocks {262
match block {263
Block::Paragraph(inline) | Block::Heading { inline, .. } => {264
for segment in &mut inline.segments {265
segment.link = None;266
segment.style.link = false;267
}268
}269
Block::Reply { children, .. } | Block::Quote(children) => unlink(children),270
Block::List { items, .. } => items.iter_mut().for_each(|item| unlink(item)),271
_ => {}272
}273
}274
}275
257
pub fn strip_image_placeholders(blocks: Vec<Block>) -> Vec<Block> {276
pub fn strip_image_placeholders(blocks: Vec<Block>) -> Vec<Block> {258
blocks277
blocks259
.into_iter()278
.into_iter()@@ -262,9 +281,15 @@ pub fn strip_image_placeholders(blocks: Vec<Block>) -> Vec<Block> {262
let stripped = inline.without(IMAGE_PLACEHOLDER);281
let stripped = inline.without(IMAGE_PLACEHOLDER);263
(!stripped.is_blank()).then_some(Block::Paragraph(stripped))282
(!stripped.is_blank()).then_some(Block::Paragraph(stripped))264
}283
}265
Block::Reply(children) => {284
Block::Reply {285
message_id,286
children,287
} => {266
let children = strip_image_placeholders(children);288
let children = strip_image_placeholders(children);267
(!children.is_empty()).then_some(Block::Reply(children))289
(!children.is_empty()).then_some(Block::Reply {290
message_id,291
children,292
})268
}293
}269
Block::Quote(children) => {294
Block::Quote(children) => {270
let children = strip_image_placeholders(children);295
let children = strip_image_placeholders(children);@@ -307,16 +332,27 @@ fn layout_blocks_with(spans: &[Span], split_images: bool) -> Vec<Block> {307
code: code.trim_end_matches('\n').to_owned(),332
code: code.trim_end_matches('\n').to_owned(),308
});333
});309
}334
}310
Span::Quote(children) | Span::BlockQuote(children) => {335
Span::Quote {336
message_id,337
children,338
} => {311
flush(&mut current, &mut blocks, Block::Paragraph);339
flush(&mut current, &mut blocks, Block::Paragraph);312
let inner = layout_blocks_with(children, false);340
let mut inner = layout_blocks_with(children, false);341
unlink(&mut inner);313
if !inner.is_empty() {342
if !inner.is_empty() {314
blocks.push(match span {343
blocks.push(Block::Reply {315
Span::Quote(_) => Block::Reply(inner),344
message_id: message_id.clone(),316
_ => Block::Quote(inner),345
children: inner,317
});346
});318
}347
}319
}348
}349
Span::BlockQuote(children) => {350
flush(&mut current, &mut blocks, Block::Paragraph);351
let inner = layout_blocks_with(children, false);352
if !inner.is_empty() {353
blocks.push(Block::Quote(inner));354
}355
}320
Span::List {356
Span::List {321
ordered,357
ordered,322
start,358
start,@@ -566,7 +602,7 @@ fn append_inline(spans: &[Span], style: StyleFlags, link: Option<&str>, out: &mu566
);602
);567
}603
}568
Span::LineBreak | Span::Rule => out.push("\n", style, link),604
Span::LineBreak | Span::Rule => out.push("\n", style, link),569
Span::Quote(children) | Span::BlockQuote(children) => {605
Span::Quote { children, .. } | Span::BlockQuote(children) => {570
append_inline(children, style, link, out);606
append_inline(children, style, link, out);571
out.push("\n", style, link);607
out.push("\n", style, link);572
}608
}@@ -828,7 +864,7 @@ mod tests {828
],864
],829
],865
],830
},866
},831
Span::Quote(vec![text("quoted")]),867
Span::Quote { message_id: Some("m1".into()), children: vec![text("quoted")] },832
]);868
]);833
assert_eq!(869
assert_eq!(834
blocks,870
blocks,@@ -848,7 +884,10 @@ mod tests {848
],884
],849
],885
],850
},886
},851
Block::Reply(vec![Block::Paragraph(Inline::plain("quoted"))]),887
Block::Reply {888
message_id: Some("m1".into()),889
children: vec![Block::Paragraph(Inline::plain("quoted"))]890
},852
]891
]853
);892
);854
}893
}@@ -6,6 +6,7 @@ use super::blocks::{Block, Inline, StyleFlags};
6
6
use super::flow_text::{FlowSegment, FlowText};
7
7
use super::selectable::{Pill, SelectableRichText};
8
8
use super::syntax::{self, Token};
9
use crate::app_state::AppHandle;
9
10
use crate::theme;
10
11
use crate::views::widgets::symbol;
11
12
@@ -46,8 +47,21 @@ fn render_block(block: &Block, id: String, own: bool, depth: usize, cx: &App) ->
46
47
.child(render_inline(inline, id, own, cx))
47
48
.into_any_element(),
48
49
Block::Code { language, code } => render_code(language.as_deref(), code, id, own, cx),
49
Block::Reply(children) => div()
50
Block::Reply {
51
message_id,
52
children,
53
} => div()
54
.id(SharedString::from(format!("{id}-reply")))
50
55
.w_full()
56
.when_some(message_id.clone(), |quote, message_id| {
57
quote
58
.cursor_pointer()
59
.hover(|quote| quote.bg(theme::row_hover()))
60
.on_click(move |_, _, cx| {
61
cx.stop_propagation();
62
jump_to_quoted(message_id.clone(), cx);
63
})
64
})
51
65
.px(px(8.))
52
66
.py(px(3.))
53
67
.border_l(px(3.))
@@ -486,3 +500,14 @@ mod tests {
486
500
assert_eq!(Rgba::from(readable(0xffd700, false)), rgb(0xffd700));
487
501
}
488
502
}
503
504
fn jump_to_quoted(message_id: String, cx: &mut App) {
505
let Some(handle) = cx.try_global::<AppHandle>() else {
506
return;
507
};
508
handle.0.clone().update(cx, |state, cx| {
509
if let Some(selection) = state.selection.clone() {
510
state.jump_to_message(selection, message_id, cx);
511
}
512
});
513
}
@@ -6,6 +6,7 @@ use super::blocks::{Block, Inline, StyleFlags};6
use super::flow_text::{FlowSegment, FlowText};6
use super::flow_text::{FlowSegment, FlowText};7
use super::selectable::{Pill, SelectableRichText};7
use super::selectable::{Pill, SelectableRichText};8
use super::syntax::{self, Token};8
use super::syntax::{self, Token};9
use crate::app_state::AppHandle;9
use crate::theme;10
use crate::theme;10
use crate::views::widgets::symbol;11
use crate::views::widgets::symbol;11
12
@@ -46,8 +47,21 @@ fn render_block(block: &Block, id: String, own: bool, depth: usize, cx: &App) ->46
.child(render_inline(inline, id, own, cx))47
.child(render_inline(inline, id, own, cx))47
.into_any_element(),48
.into_any_element(),48
Block::Code { language, code } => render_code(language.as_deref(), code, id, own, cx),49
Block::Code { language, code } => render_code(language.as_deref(), code, id, own, cx),49
Block::Reply(children) => div()50
Block::Reply {51
message_id,52
children,53
} => div()54
.id(SharedString::from(format!("{id}-reply")))50
.w_full()55
.w_full()56
.when_some(message_id.clone(), |quote, message_id| {57
quote58
.cursor_pointer()59
.hover(|quote| quote.bg(theme::row_hover()))60
.on_click(move |_, _, cx| {61
cx.stop_propagation();62
jump_to_quoted(message_id.clone(), cx);63
})64
})51
.px(px(8.))65
.px(px(8.))52
.py(px(3.))66
.py(px(3.))53
.border_l(px(3.))67
.border_l(px(3.))@@ -486,3 +500,14 @@ mod tests {486
assert_eq!(Rgba::from(readable(0xffd700, false)), rgb(0xffd700));500
assert_eq!(Rgba::from(readable(0xffd700, false)), rgb(0xffd700));487
}501
}488
}502
}503
504
fn jump_to_quoted(message_id: String, cx: &mut App) {505
let Some(handle) = cx.try_global::<AppHandle>() else {506
return;507
};508
handle.0.clone().update(cx, |state, cx| {509
if let Some(selection) = state.selection.clone() {510
state.jump_to_message(selection, message_id, cx);511
}512
});513
}@@ -468,7 +468,7 @@ const FORWARD_ITEMTYPE: &str = "schema.skype.com/Forward";
468
468
pub fn message_text(record: &MessageRecord) -> String {
469
469
let own_spans: Vec<Span> = message_spans(record)
470
470
.into_iter()
471
.filter(|span| !matches!(span, Span::Quote(_)))
471
.filter(|span| !matches!(span, Span::Quote { .. }))
472
472
.collect();
473
473
strip_image_placeholders(layout_blocks(&own_spans))
474
474
.into_iter()
@@ -481,7 +481,7 @@ pub fn message_text(record: &MessageRecord) -> String {
481
481
pub fn message_draft(record: &MessageRecord) -> Draft {
482
482
let own_spans: Vec<Span> = message_spans(record)
483
483
.into_iter()
484
.filter(|span| !matches!(span, Span::Quote(_)))
484
.filter(|span| !matches!(span, Span::Quote { .. }))
485
485
.collect();
486
486
Draft::from_spans(&own_spans).trimmed()
487
487
}
@@ -489,7 +489,7 @@ pub fn message_draft(record: &MessageRecord) -> Draft {
489
489
pub fn reply_excerpt(record: &MessageRecord) -> String {
490
490
let own_spans: Vec<Span> = message_spans(record)
491
491
.into_iter()
492
.filter(|span| !matches!(span, Span::Quote(_)))
492
.filter(|span| !matches!(span, Span::Quote { .. }))
493
493
.collect();
494
494
let text = strip_image_placeholders(layout_blocks(&own_spans))
495
495
.into_iter()
@@ -984,7 +984,7 @@ mod tests {
984
984
_ => None,
985
985
})
986
986
.unwrap();
987
let Some(Block::Reply(children)) = reply.first() else { panic!("{reply:?}") };
987
let Some(Block::Reply { children, .. }) = reply.first() else { panic!("{reply:?}") };
988
988
let text = format!("{children:?}");
989
989
assert!(text.contains(r"first link\nsecond link"), "{text}");
990
990
}
@@ -468,7 +468,7 @@ const FORWARD_ITEMTYPE: &str = "schema.skype.com/Forward";468
pub fn message_text(record: &MessageRecord) -> String {468
pub fn message_text(record: &MessageRecord) -> String {469
let own_spans: Vec<Span> = message_spans(record)469
let own_spans: Vec<Span> = message_spans(record)470
.into_iter()470
.into_iter()471
.filter(|span| !matches!(span, Span::Quote(_)))471
.filter(|span| !matches!(span, Span::Quote { .. }))472
.collect();472
.collect();473
strip_image_placeholders(layout_blocks(&own_spans))473
strip_image_placeholders(layout_blocks(&own_spans))474
.into_iter()474
.into_iter()@@ -481,7 +481,7 @@ pub fn message_text(record: &MessageRecord) -> String {481
pub fn message_draft(record: &MessageRecord) -> Draft {481
pub fn message_draft(record: &MessageRecord) -> Draft {482
let own_spans: Vec<Span> = message_spans(record)482
let own_spans: Vec<Span> = message_spans(record)483
.into_iter()483
.into_iter()484
.filter(|span| !matches!(span, Span::Quote(_)))484
.filter(|span| !matches!(span, Span::Quote { .. }))485
.collect();485
.collect();486
Draft::from_spans(&own_spans).trimmed()486
Draft::from_spans(&own_spans).trimmed()487
}487
}@@ -489,7 +489,7 @@ pub fn message_draft(record: &MessageRecord) -> Draft {489
pub fn reply_excerpt(record: &MessageRecord) -> String {489
pub fn reply_excerpt(record: &MessageRecord) -> String {490
let own_spans: Vec<Span> = message_spans(record)490
let own_spans: Vec<Span> = message_spans(record)491
.into_iter()491
.into_iter()492
.filter(|span| !matches!(span, Span::Quote(_)))492
.filter(|span| !matches!(span, Span::Quote { .. }))493
.collect();493
.collect();494
let text = strip_image_placeholders(layout_blocks(&own_spans))494
let text = strip_image_placeholders(layout_blocks(&own_spans))495
.into_iter()495
.into_iter()@@ -984,7 +984,7 @@ mod tests {984
_ => None,984
_ => None,985
})985
})986
.unwrap();986
.unwrap();987
let Some(Block::Reply(children)) = reply.first() else { panic!("{reply:?}") };987
let Some(Block::Reply { children, .. }) = reply.first() else { panic!("{reply:?}") };988
let text = format!("{children:?}");988
let text = format!("{children:?}");989
assert!(text.contains(r"first link\nsecond link"), "{text}");989
assert!(text.contains(r"first link\nsecond link"), "{text}");990
}990
}@@ -1988,7 +1988,7 @@ impl SpanLines {
1988
1988
}
1989
1989
self.open = false;
1990
1990
}
1991
Span::Image { .. } | Span::Quote(_) => {}
1991
Span::Image { .. } | Span::Quote { .. } => {}
1992
1992
}
1993
1993
}
1994
1994
}
@@ -1988,7 +1988,7 @@ impl SpanLines {1988
}1988
}1989
self.open = false;1989
self.open = false;1990
}1990
}1991
Span::Image { .. } | Span::Quote(_) => {}1991
Span::Image { .. } | Span::Quote { .. } => {}1992
}1992
}1993
}1993
}1994
}1994
}@@ -54,7 +54,10 @@ pub enum Span {
54
54
Image {
55
55
hosted_content_url: String,
56
56
},
57
Quote(Vec<Span>),
57
Quote {
58
message_id: Option<String>,
59
children: Vec<Span>,
60
},
58
61
BlockQuote(Vec<Span>),
59
62
}
60
63
@@ -142,7 +145,10 @@ fn convert_element(element: ElementRef<'_>, spans: &mut Vec<Span>) {
142
145
start: 1,
143
146
items: vec![convert_children(element)],
144
147
}),
145
"blockquote" if is_reply(element) => spans.push(Span::Quote(convert_children(element))),
148
"blockquote" if is_reply(element) => spans.push(Span::Quote {
149
message_id: element.value().attr("itemid").map(str::to_owned),
150
children: convert_children(element),
151
}),
146
152
"blockquote" => spans.push(Span::BlockQuote(convert_children(element))),
147
153
"emoji" => push_emoji(element, spans),
148
154
"img" => push_image(element, spans),
@@ -416,7 +422,7 @@ fn tidy(spans: &mut Vec<Span>) {
416
422
| Span::Underline(children)
417
423
| Span::Colored { children, .. }
418
424
| Span::Heading { children, .. }
419
| Span::Quote(children)
425
| Span::Quote { children, .. }
420
426
| Span::BlockQuote(children)
421
427
| Span::Link { children, .. } => tidy(children),
422
428
Span::List { items, .. } => items.iter_mut().for_each(tidy),
@@ -447,7 +453,7 @@ fn collapse_whitespace(spans: &mut Vec<Span>) {
447
453
| Span::List { .. }
448
454
| Span::Table { .. }
449
455
| Span::Heading { .. }
450
| Span::Quote(_)
456
| Span::Quote { .. }
451
457
| Span::BlockQuote(_)
452
458
)
453
459
)
@@ -54,7 +54,10 @@ pub enum Span {54
Image {54
Image {55
hosted_content_url: String,55
hosted_content_url: String,56
},56
},57
Quote(Vec<Span>),57
Quote {58
message_id: Option<String>,59
children: Vec<Span>,60
},58
BlockQuote(Vec<Span>),61
BlockQuote(Vec<Span>),59
}62
}60
63
@@ -142,7 +145,10 @@ fn convert_element(element: ElementRef<'_>, spans: &mut Vec<Span>) {142
start: 1,145
start: 1,143
items: vec![convert_children(element)],146
items: vec![convert_children(element)],144
}),147
}),145
"blockquote" if is_reply(element) => spans.push(Span::Quote(convert_children(element))),148
"blockquote" if is_reply(element) => spans.push(Span::Quote {149
message_id: element.value().attr("itemid").map(str::to_owned),150
children: convert_children(element),151
}),146
"blockquote" => spans.push(Span::BlockQuote(convert_children(element))),152
"blockquote" => spans.push(Span::BlockQuote(convert_children(element))),147
"emoji" => push_emoji(element, spans),153
"emoji" => push_emoji(element, spans),148
"img" => push_image(element, spans),154
"img" => push_image(element, spans),@@ -416,7 +422,7 @@ fn tidy(spans: &mut Vec<Span>) {416
| Span::Underline(children)422
| Span::Underline(children)417
| Span::Colored { children, .. }423
| Span::Colored { children, .. }418
| Span::Heading { children, .. }424
| Span::Heading { children, .. }419
| Span::Quote(children)425
| Span::Quote { children, .. }420
| Span::BlockQuote(children)426
| Span::BlockQuote(children)421
| Span::Link { children, .. } => tidy(children),427
| Span::Link { children, .. } => tidy(children),422
Span::List { items, .. } => items.iter_mut().for_each(tidy),428
Span::List { items, .. } => items.iter_mut().for_each(tidy),@@ -447,7 +453,7 @@ fn collapse_whitespace(spans: &mut Vec<Span>) {447
| Span::List { .. }453
| Span::List { .. }448
| Span::Table { .. }454
| Span::Table { .. }449
| Span::Heading { .. }455
| Span::Heading { .. }450
| Span::Quote(_)456
| Span::Quote { .. }451
| Span::BlockQuote(_)457
| Span::BlockQuote(_)452
)458
)453
)459
)@@ -395,7 +395,7 @@ pub fn readable_text(record: &MessageRecord) -> String {
395
395
}
396
396
let spans: Vec<Span> = message_spans(record)
397
397
.into_iter()
398
.filter(|span| !matches!(span, Span::Quote(_)))
398
.filter(|span| !matches!(span, Span::Quote { .. }))
399
399
.collect();
400
400
let mut text = String::new();
401
401
push_plain(&mut text, &spans);
@@ -468,7 +468,7 @@ pub(crate) fn push_plain(text: &mut String, spans: &[Span]) {
468
468
| Span::Sized(_, children)
469
469
| Span::Underline(children)
470
470
| Span::Colored { children, .. }
471
| Span::Quote(children)
471
| Span::Quote { children, .. }
472
472
| Span::BlockQuote(children)
473
473
| Span::Link { children, .. } => push_plain(text, children),
474
474
Span::Heading { children, .. } => {
@@ -592,7 +592,7 @@ fn link_user_mentions(spans: &mut [Span], infos: &[MentionInfo]) {
592
592
| Span::Underline(children)
593
593
| Span::Colored { children, .. }
594
594
| Span::Heading { children, .. }
595
| Span::Quote(children)
595
| Span::Quote { children, .. }
596
596
| Span::BlockQuote(children)
597
597
| Span::Link { children, .. } => link_user_mentions(children, infos),
598
598
Span::List { items, .. } => items
@@ -685,7 +685,7 @@ fn collect_user_mentions(spans: &[Span], infos: &[MentionInfo], inputs: &mut Vec
685
685
| Span::Underline(children)
686
686
| Span::Colored { children, .. }
687
687
| Span::Heading { children, .. }
688
| Span::Quote(children)
688
| Span::Quote { children, .. }
689
689
| Span::BlockQuote(children)
690
690
| Span::Link { children, .. } => collect_user_mentions(children, infos, inputs),
691
691
Span::List { items, .. } => items
@@ -731,7 +731,7 @@ fn merge_split_mentions(spans: &mut Vec<Span>, mentions: &[MentionInfo]) {
731
731
| Span::Underline(children)
732
732
| Span::Colored { children, .. }
733
733
| Span::Heading { children, .. }
734
| Span::Quote(children)
734
| Span::Quote { children, .. }
735
735
| Span::BlockQuote(children)
736
736
| Span::Link { children, .. } => merge_split_mentions(children, mentions),
737
737
Span::List { items, .. } => items
@@ -1120,7 +1120,7 @@ mod tests {
1120
1120
json,
1121
1121
);
1122
1122
let spans = message_spans(&stored);
1123
let Some(Span::Quote(children)) = spans.first() else {
1123
let Some(Span::Quote { children, .. }) = spans.first() else {
1124
1124
panic!("expected a reply quote first, got {spans:?}");
1125
1125
};
1126
1126
let mut quoted = String::new();
@@ -1136,7 +1136,7 @@ mod tests {
1136
1136
fn a_message_reference_without_its_tag_still_shows_the_quote() {
1137
1137
let json = r#"[{"content_type":"messageReference","name":null,"url":null,"text":null,"quote":{"message_id":"Q1","preview":"hi","sender_name":null}}]"#;
1138
1138
let spans = message_spans(&record("<p>answer</p>", json));
1139
assert!(matches!(spans.first(), Some(Span::Quote(_))));
1139
assert!(matches!(spans.first(), Some(Span::Quote { .. })));
1140
1140
}
1141
1141
1142
1142
fn with_mentions(body_html: &str, mentions_json: &str) -> MessageRecord {
@@ -395,7 +395,7 @@ pub fn readable_text(record: &MessageRecord) -> String {395
}395
}396
let spans: Vec<Span> = message_spans(record)396
let spans: Vec<Span> = message_spans(record)397
.into_iter()397
.into_iter()398
.filter(|span| !matches!(span, Span::Quote(_)))398
.filter(|span| !matches!(span, Span::Quote { .. }))399
.collect();399
.collect();400
let mut text = String::new();400
let mut text = String::new();401
push_plain(&mut text, &spans);401
push_plain(&mut text, &spans);@@ -468,7 +468,7 @@ pub(crate) fn push_plain(text: &mut String, spans: &[Span]) {468
| Span::Sized(_, children)468
| Span::Sized(_, children)469
| Span::Underline(children)469
| Span::Underline(children)470
| Span::Colored { children, .. }470
| Span::Colored { children, .. }471
| Span::Quote(children)471
| Span::Quote { children, .. }472
| Span::BlockQuote(children)472
| Span::BlockQuote(children)473
| Span::Link { children, .. } => push_plain(text, children),473
| Span::Link { children, .. } => push_plain(text, children),474
Span::Heading { children, .. } => {474
Span::Heading { children, .. } => {@@ -592,7 +592,7 @@ fn link_user_mentions(spans: &mut [Span], infos: &[MentionInfo]) {592
| Span::Underline(children)592
| Span::Underline(children)593
| Span::Colored { children, .. }593
| Span::Colored { children, .. }594
| Span::Heading { children, .. }594
| Span::Heading { children, .. }595
| Span::Quote(children)595
| Span::Quote { children, .. }596
| Span::BlockQuote(children)596
| Span::BlockQuote(children)597
| Span::Link { children, .. } => link_user_mentions(children, infos),597
| Span::Link { children, .. } => link_user_mentions(children, infos),598
Span::List { items, .. } => items598
Span::List { items, .. } => items@@ -685,7 +685,7 @@ fn collect_user_mentions(spans: &[Span], infos: &[MentionInfo], inputs: &mut Vec685
| Span::Underline(children)685
| Span::Underline(children)686
| Span::Colored { children, .. }686
| Span::Colored { children, .. }687
| Span::Heading { children, .. }687
| Span::Heading { children, .. }688
| Span::Quote(children)688
| Span::Quote { children, .. }689
| Span::BlockQuote(children)689
| Span::BlockQuote(children)690
| Span::Link { children, .. } => collect_user_mentions(children, infos, inputs),690
| Span::Link { children, .. } => collect_user_mentions(children, infos, inputs),691
Span::List { items, .. } => items691
Span::List { items, .. } => items@@ -731,7 +731,7 @@ fn merge_split_mentions(spans: &mut Vec<Span>, mentions: &[MentionInfo]) {731
| Span::Underline(children)731
| Span::Underline(children)732
| Span::Colored { children, .. }732
| Span::Colored { children, .. }733
| Span::Heading { children, .. }733
| Span::Heading { children, .. }734
| Span::Quote(children)734
| Span::Quote { children, .. }735
| Span::BlockQuote(children)735
| Span::BlockQuote(children)736
| Span::Link { children, .. } => merge_split_mentions(children, mentions),736
| Span::Link { children, .. } => merge_split_mentions(children, mentions),737
Span::List { items, .. } => items737
Span::List { items, .. } => items@@ -1120,7 +1120,7 @@ mod tests {1120
json,1120
json,1121
);1121
);1122
let spans = message_spans(&stored);1122
let spans = message_spans(&stored);1123
let Some(Span::Quote(children)) = spans.first() else {1123
let Some(Span::Quote { children, .. }) = spans.first() else {1124
panic!("expected a reply quote first, got {spans:?}");1124
panic!("expected a reply quote first, got {spans:?}");1125
};1125
};1126
let mut quoted = String::new();1126
let mut quoted = String::new();@@ -1136,7 +1136,7 @@ mod tests {1136
fn a_message_reference_without_its_tag_still_shows_the_quote() {1136
fn a_message_reference_without_its_tag_still_shows_the_quote() {1137
let json = r#"[{"content_type":"messageReference","name":null,"url":null,"text":null,"quote":{"message_id":"Q1","preview":"hi","sender_name":null}}]"#;1137
let json = r#"[{"content_type":"messageReference","name":null,"url":null,"text":null,"quote":{"message_id":"Q1","preview":"hi","sender_name":null}}]"#;1138
let spans = message_spans(&record("<p>answer</p>", json));1138
let spans = message_spans(&record("<p>answer</p>", json));1139
assert!(matches!(spans.first(), Some(Span::Quote(_))));1139
assert!(matches!(spans.first(), Some(Span::Quote { .. })));1140
}1140
}1141
1141
1142
fn with_mentions(body_html: &str, mentions_json: &str) -> MessageRecord {1142
fn with_mentions(body_html: &str, mentions_json: &str) -> MessageRecord {@@ -166,12 +166,12 @@ fn reply_quote() {
166
166
assert_eq!(
167
167
html_to_spans(html),
168
168
vec![
169
Span::Quote(vec![
169
Span::Quote { message_id: Some("170".into()), children: vec![
170
170
Span::Bold(vec![text("Bob Sample")]),
171
171
text("12:01"),
172
172
Span::LineBreak,
173
173
text("original text"),
174
]),
174
] },
175
175
Span::LineBreak,
176
176
text("my answer"),
177
177
]
@@ -166,12 +166,12 @@ fn reply_quote() {166
assert_eq!(166
assert_eq!(167
html_to_spans(html),167
html_to_spans(html),168
vec![168
vec![169
Span::Quote(vec![169
Span::Quote { message_id: Some("170".into()), children: vec![170
Span::Bold(vec![text("Bob Sample")]),170
Span::Bold(vec![text("Bob Sample")]),171
text("12:01"),171
text("12:01"),172
Span::LineBreak,172
Span::LineBreak,173
text("original text"),173
text("original text"),174
]),174
] },175
Span::LineBreak,175
Span::LineBreak,176
text("my answer"),176
text("my answer"),177
]177
]