diff --git a/crates/typst-ide/src/complete.rs b/crates/typst-ide/src/complete.rs index bc5b3e10e..9c7d9d2f0 100644 --- a/crates/typst-ide/src/complete.rs +++ b/crates/typst-ide/src/complete.rs @@ -98,7 +98,7 @@ pub enum CompletionKind { /// A font family. Font, /// A symbol. - Symbol(char), + Symbol(EcoString), } /// Complete in comments. Or rather, don't! @@ -450,7 +450,7 @@ fn field_access_completions( for modifier in symbol.modifiers() { if let Ok(modified) = symbol.clone().modified((), modifier) { ctx.completions.push(Completion { - kind: CompletionKind::Symbol(modified.get()), + kind: CompletionKind::Symbol(modified.get().into()), label: modifier.into(), apply: None, detail: None, @@ -1385,7 +1385,7 @@ impl<'a> CompletionContext<'a> { kind: kind.unwrap_or_else(|| match value { Value::Func(_) => CompletionKind::Func, Value::Type(_) => CompletionKind::Type, - Value::Symbol(s) => CompletionKind::Symbol(s.get()), + Value::Symbol(s) => CompletionKind::Symbol(s.get().into()), _ => CompletionKind::Constant, }), label, diff --git a/docs/src/lib.rs b/docs/src/lib.rs index e3eb21f98..063f1676f 100644 --- a/docs/src/lib.rs +++ b/docs/src/lib.rs @@ -718,9 +718,13 @@ fn symbols_model(resolver: &dyn Resolver, group: &GroupData) -> SymbolsModel { } }; - for (variant, c, deprecation) in symbol.variants() { + for (variant, value, deprecation) in symbol.variants() { + let value_char = value.parse::().ok(); + let shorthand = |list: &[(&'static str, char)]| { - list.iter().copied().find(|&(_, x)| x == c).map(|(s, _)| s) + value_char.and_then(|c| { + list.iter().copied().find(|&(_, x)| x == c).map(|(s, _)| s) + }) }; let name = complete(variant); @@ -729,9 +733,12 @@ fn symbols_model(resolver: &dyn Resolver, group: &GroupData) -> SymbolsModel { name, markup_shorthand: shorthand(typst::syntax::ast::Shorthand::LIST), math_shorthand: shorthand(typst::syntax::ast::MathShorthand::LIST), - math_class: typst_utils::default_math_class(c).map(math_class_name), - codepoint: c as _, - accent: typst::math::Accent::combine(c).is_some(), + math_class: value_char.and_then(|c| { + typst_utils::default_math_class(c).map(math_class_name) + }), + value: value.into(), + accent: value_char + .is_some_and(|c| typst::math::Accent::combine(c).is_some()), alternates: symbol .variants() .filter(|(other, _, _)| other != &variant) diff --git a/docs/src/model.rs b/docs/src/model.rs index 801c60c7f..d061a5c45 100644 --- a/docs/src/model.rs +++ b/docs/src/model.rs @@ -159,7 +159,7 @@ pub struct SymbolsModel { #[serde(rename_all = "camelCase")] pub struct SymbolModel { pub name: EcoString, - pub codepoint: u32, + pub value: EcoString, pub accent: bool, pub alternates: Vec, pub markup_shorthand: Option<&'static str>,