From 6343237c7763e9f203d80fcb4b0f9f682a165eb5 Mon Sep 17 00:00:00 2001 From: Said Aroua Date: Fri, 27 Jun 2025 18:09:07 +0200 Subject: [PATCH] Dedpulicate labels for code completion --- crates/typst-ide/src/analyze.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/crates/typst-ide/src/analyze.rs b/crates/typst-ide/src/analyze.rs index 76739fec0..e9fb8a7d7 100644 --- a/crates/typst-ide/src/analyze.rs +++ b/crates/typst-ide/src/analyze.rs @@ -1,3 +1,5 @@ +use std::collections::HashSet; + use comemo::Track; use ecow::{eco_vec, EcoString, EcoVec}; use typst::foundations::{Label, Styles, Value}; @@ -66,14 +68,22 @@ pub fn analyze_import(world: &dyn IdeWorld, source: &LinkedNode) -> Option (Vec<(Label, Option)>, usize) { let mut output = vec![]; + let mut seen_labels = HashSet::new(); // Labels in the document. for elem in document.introspector.all() { let Some(label) = elem.label() else { continue }; + if !seen_labels.insert(label) { + continue; + } + let details = elem .to_packed::() .and_then(|figure| match figure.caption.as_option() {