summaryrefslogtreecommitdiff
path: root/crates/typst-ide
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2024-11-29 16:03:08 +0100
committerGitHub <noreply@github.com>2024-11-29 15:03:08 +0000
commitd40c8ab6ab4f7051a12e5ce9433439f3a5afb99f (patch)
tree8e5b2972b1c5ede14a05ae5525c4a07fb3dda300 /crates/typst-ide
parent055263ee9f2253de9f176970df9d47d3b2bd2467 (diff)
Compile-time `PicoStr` interning (#5491)
Diffstat (limited to 'crates/typst-ide')
-rw-r--r--crates/typst-ide/src/analyze.rs4
-rw-r--r--crates/typst-ide/src/complete.rs4
-rw-r--r--crates/typst-ide/src/definition.rs3
-rw-r--r--crates/typst-ide/src/tooltip.rs2
4 files changed, 6 insertions, 7 deletions
diff --git a/crates/typst-ide/src/analyze.rs b/crates/typst-ide/src/analyze.rs
index 5e3dfd70..eaf7248b 100644
--- a/crates/typst-ide/src/analyze.rs
+++ b/crates/typst-ide/src/analyze.rs
@@ -88,9 +88,7 @@ pub fn analyze_labels(document: &Document) -> (Vec<(Label, Option<EcoString>)>,
let split = output.len();
// Bibliography keys.
- for (key, detail) in BibliographyElem::keys(document.introspector.track()) {
- output.push((Label::new(key.as_str()), detail));
- }
+ output.extend(BibliographyElem::keys(document.introspector.track()));
(output, split)
}
diff --git a/crates/typst-ide/src/complete.rs b/crates/typst-ide/src/complete.rs
index a2791e07..510db54c 100644
--- a/crates/typst-ide/src/complete.rs
+++ b/crates/typst-ide/src/complete.rs
@@ -1254,11 +1254,11 @@ impl<'a> CompletionContext<'a> {
eco_format!(
"{}{}{}",
if open { "<" } else { "" },
- label.as_str(),
+ label.resolve(),
if close { ">" } else { "" }
)
}),
- label: label.as_str().into(),
+ label: label.resolve().as_str().into(),
detail,
});
}
diff --git a/crates/typst-ide/src/definition.rs b/crates/typst-ide/src/definition.rs
index 94def1c1..9303aee4 100644
--- a/crates/typst-ide/src/definition.rs
+++ b/crates/typst-ide/src/definition.rs
@@ -1,6 +1,7 @@
use typst::foundations::{Label, Selector, Value};
use typst::model::Document;
use typst::syntax::{ast, LinkedNode, Side, Source, Span};
+use typst::utils::PicoStr;
use crate::utils::globals;
use crate::{
@@ -71,7 +72,7 @@ pub fn definition(
// Try to jump to the referenced content.
DerefTarget::Ref(node) => {
- let label = Label::new(node.cast::<ast::Ref>()?.target());
+ let label = Label::new(PicoStr::intern(node.cast::<ast::Ref>()?.target()));
let selector = Selector::Label(label);
let elem = document?.introspector.query_first(&selector)?;
return Some(Definition::Span(elem.span()));
diff --git a/crates/typst-ide/src/tooltip.rs b/crates/typst-ide/src/tooltip.rs
index d6282652..30aca24f 100644
--- a/crates/typst-ide/src/tooltip.rs
+++ b/crates/typst-ide/src/tooltip.rs
@@ -181,7 +181,7 @@ fn label_tooltip(document: &Document, leaf: &LinkedNode) -> Option<Tooltip> {
};
for (label, detail) in analyze_labels(document).0 {
- if label.as_str() == target {
+ if label.resolve().as_str() == target {
return Some(Tooltip::Text(detail?));
}
}