diff options
| author | Laurenz <laurmaedje@gmail.com> | 2023-03-13 11:30:17 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2023-03-13 11:30:17 +0100 |
| commit | 8debba439cbaa02faddcd3797841d7232d82e820 (patch) | |
| tree | 9bf0df5fe3f21a5d8e38496c4063d9b355d20553 /src | |
| parent | 74ab0309f03db1b13247f18152c29398bf293845 (diff) | |
Fix font tooltip
Diffstat (limited to 'src')
| -rw-r--r-- | src/ide/complete.rs | 2 | ||||
| -rw-r--r-- | src/ide/tooltip.rs | 20 |
2 files changed, 6 insertions, 16 deletions
diff --git a/src/ide/complete.rs b/src/ide/complete.rs index a7b001ae..de6f2b73 100644 --- a/src/ide/complete.rs +++ b/src/ide/complete.rs @@ -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(); while !matches!( deciding.kind(), diff --git a/src/ide/tooltip.rs b/src/ide/tooltip.rs index 4f281050..a32dfb0b 100644 --- a/src/ide/tooltip.rs +++ b/src/ide/tooltip.rs @@ -21,7 +21,7 @@ pub fn tooltip( let leaf = LinkedNode::new(source.root()).leaf_at(cursor)?; named_param_tooltip(world, &leaf) - .or_else(|| font_family_tooltip(world, &leaf)) + .or_else(|| font_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. -fn font_family_tooltip( - world: &(dyn World + 'static), - leaf: &LinkedNode, -) -> Option<Tooltip> { +/// Tooltip for font. +fn font_tooltip(world: &dyn World, leaf: &LinkedNode) -> Option<Tooltip> { if_chain! { // Ensure that we are on top of a string. 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. if let Some(parent) = leaf.parent(); - if matches!(parent.kind(), SyntaxKind::Args); - if let Some(grand) = parent.parent(); - 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, - }; + if let Some(named) = parent.cast::<ast::Named>(); + if named.name().as_str() == "font"; // Find the font family. - if callee.as_str() == "text"; if let Some((_, iter)) = world .book() .families() |
