summaryrefslogtreecommitdiffstats
path: root/widget
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2025-02-02 04:17:44 +0100
committerLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2025-02-02 04:17:44 +0100
commit599d8b560bec8036c5ddda62a7bf0a540bdec396 (patch)
tree2ff9ac62496574cb71e6ff430fa272b4bcf19a81 /widget
parent569ef13ac96b2a77dd919c9f15fffd8179cbec28 (diff)
downloadiced-599d8b560bec8036c5ddda62a7bf0a540bdec396.tar.gz
iced-599d8b560bec8036c5ddda62a7bf0a540bdec396.tar.bz2
iced-599d8b560bec8036c5ddda62a7bf0a540bdec396.zip
Avoid sharing `State` when re-parsing `markdown` sections
Diffstat (limited to 'widget')
-rw-r--r--widget/src/markdown.rs14
1 files changed, 8 insertions, 6 deletions
diff --git a/widget/src/markdown.rs b/widget/src/markdown.rs
index ea00d14f..858ee281 100644
--- a/widget/src/markdown.rs
+++ b/widget/src/markdown.rs
@@ -129,12 +129,6 @@ impl Content {
// Re-parse incomplete sections if new references are available
if !self.incomplete.is_empty() {
- let mut state = State {
- leftover: String::new(),
- references: self.state.references.clone(),
- highlighter: None,
- };
-
self.incomplete.retain(|index, section| {
if self.items.len() <= *index {
return false;
@@ -147,11 +141,19 @@ impl Content {
.retain(|link| !self.state.references.contains_key(link));
if broken_links_before != section.broken_links.len() {
+ let mut state = State {
+ leftover: String::new(),
+ references: self.state.references.clone(),
+ highlighter: None,
+ };
+
if let Some((item, _source, _broken_links)) =
parse_with(&mut state, &section.content).next()
{
self.items[*index] = item;
}
+
+ drop(state);
}
!section.broken_links.is_empty()