mirror of
https://github.com/typst/typst
synced 2025-07-27 06:17:53 +08:00
Fix ide and docs
This commit is contained in:
parent
fd35268a88
commit
476096c2db
@ -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,
|
||||
|
@ -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)]| {
|
||||
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)
|
||||
|
@ -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<EcoString>,
|
||||
pub markup_shorthand: Option<&'static str>,
|
||||
|
Loading…
x
Reference in New Issue
Block a user