mirror of
https://github.com/typst/typst
synced 2025-05-14 17:15:28 +08:00
Fix font tooltip
This commit is contained in:
parent
74ab0309f0
commit
8debba439c
@ -562,7 +562,7 @@ fn complete_params(ctx: &mut CompletionContext) -> bool {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Find the piece of syntax that decides what we're completion.
|
// Find the piece of syntax that decides what we're completing.
|
||||||
let mut deciding = ctx.leaf.clone();
|
let mut deciding = ctx.leaf.clone();
|
||||||
while !matches!(
|
while !matches!(
|
||||||
deciding.kind(),
|
deciding.kind(),
|
||||||
|
@ -21,7 +21,7 @@ pub fn tooltip(
|
|||||||
let leaf = LinkedNode::new(source.root()).leaf_at(cursor)?;
|
let leaf = LinkedNode::new(source.root()).leaf_at(cursor)?;
|
||||||
|
|
||||||
named_param_tooltip(world, &leaf)
|
named_param_tooltip(world, &leaf)
|
||||||
.or_else(|| font_family_tooltip(world, &leaf))
|
.or_else(|| font_tooltip(world, &leaf))
|
||||||
.or_else(|| expr_tooltip(world, &leaf))
|
.or_else(|| expr_tooltip(world, &leaf))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,11 +162,8 @@ fn find_string_doc(info: &CastInfo, string: &str) -> Option<&'static str> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Tooltip for font family.
|
/// Tooltip for font.
|
||||||
fn font_family_tooltip(
|
fn font_tooltip(world: &dyn World, leaf: &LinkedNode) -> Option<Tooltip> {
|
||||||
world: &(dyn World + 'static),
|
|
||||||
leaf: &LinkedNode,
|
|
||||||
) -> Option<Tooltip> {
|
|
||||||
if_chain! {
|
if_chain! {
|
||||||
// Ensure that we are on top of a string.
|
// Ensure that we are on top of a string.
|
||||||
if let Some(string) = leaf.cast::<ast::Str>();
|
if let Some(string) = leaf.cast::<ast::Str>();
|
||||||
@ -174,17 +171,10 @@ fn font_family_tooltip(
|
|||||||
|
|
||||||
// Ensure that we are in the arguments to the text function.
|
// Ensure that we are in the arguments to the text function.
|
||||||
if let Some(parent) = leaf.parent();
|
if let Some(parent) = leaf.parent();
|
||||||
if matches!(parent.kind(), SyntaxKind::Args);
|
if let Some(named) = parent.cast::<ast::Named>();
|
||||||
if let Some(grand) = parent.parent();
|
if named.name().as_str() == "font";
|
||||||
if let Some(expr) = grand.cast::<ast::Expr>();
|
|
||||||
if let Some(ast::Expr::Ident(callee)) = match expr {
|
|
||||||
ast::Expr::FuncCall(call) => Some(call.callee()),
|
|
||||||
ast::Expr::Set(set) => Some(set.target()),
|
|
||||||
_ => None,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Find the font family.
|
// Find the font family.
|
||||||
if callee.as_str() == "text";
|
|
||||||
if let Some((_, iter)) = world
|
if let Some((_, iter)) = world
|
||||||
.book()
|
.book()
|
||||||
.families()
|
.families()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user