Fix ide and docs

This commit is contained in:
T0mstone 2025-07-10 02:28:00 +02:00
parent fd35268a88
commit 476096c2db
3 changed files with 16 additions and 9 deletions

View File

@ -98,7 +98,7 @@ pub enum CompletionKind {
/// A font family. /// A font family.
Font, Font,
/// A symbol. /// A symbol.
Symbol(char), Symbol(EcoString),
} }
/// Complete in comments. Or rather, don't! /// Complete in comments. Or rather, don't!
@ -450,7 +450,7 @@ fn field_access_completions(
for modifier in symbol.modifiers() { for modifier in symbol.modifiers() {
if let Ok(modified) = symbol.clone().modified((), modifier) { if let Ok(modified) = symbol.clone().modified((), modifier) {
ctx.completions.push(Completion { ctx.completions.push(Completion {
kind: CompletionKind::Symbol(modified.get()), kind: CompletionKind::Symbol(modified.get().into()),
label: modifier.into(), label: modifier.into(),
apply: None, apply: None,
detail: None, detail: None,
@ -1385,7 +1385,7 @@ impl<'a> CompletionContext<'a> {
kind: kind.unwrap_or_else(|| match value { kind: kind.unwrap_or_else(|| match value {
Value::Func(_) => CompletionKind::Func, Value::Func(_) => CompletionKind::Func,
Value::Type(_) => CompletionKind::Type, Value::Type(_) => CompletionKind::Type,
Value::Symbol(s) => CompletionKind::Symbol(s.get()), Value::Symbol(s) => CompletionKind::Symbol(s.get().into()),
_ => CompletionKind::Constant, _ => CompletionKind::Constant,
}), }),
label, label,

View File

@ -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::<char>().ok();
let shorthand = |list: &[(&'static str, char)]| { 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); let name = complete(variant);
@ -729,9 +733,12 @@ fn symbols_model(resolver: &dyn Resolver, group: &GroupData) -> SymbolsModel {
name, name,
markup_shorthand: shorthand(typst::syntax::ast::Shorthand::LIST), markup_shorthand: shorthand(typst::syntax::ast::Shorthand::LIST),
math_shorthand: shorthand(typst::syntax::ast::MathShorthand::LIST), math_shorthand: shorthand(typst::syntax::ast::MathShorthand::LIST),
math_class: typst_utils::default_math_class(c).map(math_class_name), math_class: value_char.and_then(|c| {
codepoint: c as _, typst_utils::default_math_class(c).map(math_class_name)
accent: typst::math::Accent::combine(c).is_some(), }),
value: value.into(),
accent: value_char
.is_some_and(|c| typst::math::Accent::combine(c).is_some()),
alternates: symbol alternates: symbol
.variants() .variants()
.filter(|(other, _, _)| other != &variant) .filter(|(other, _, _)| other != &variant)

View File

@ -159,7 +159,7 @@ pub struct SymbolsModel {
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct SymbolModel { pub struct SymbolModel {
pub name: EcoString, pub name: EcoString,
pub codepoint: u32, pub value: EcoString,
pub accent: bool, pub accent: bool,
pub alternates: Vec<EcoString>, pub alternates: Vec<EcoString>,
pub markup_shorthand: Option<&'static str>, pub markup_shorthand: Option<&'static str>,