@@ -12,7 +12,7 @@ use stdx::format_to;
1212use syntax:: {
1313 algo,
1414 ast:: { self , HasArgList } ,
15- match_ast, AstNode , Direction , SyntaxKind , SyntaxToken , TextRange , TextSize ,
15+ match_ast, AstNode , Direction , SyntaxToken , TextRange , TextSize ,
1616} ;
1717
1818use crate :: RootDatabase ;
@@ -105,10 +105,10 @@ pub(crate) fn signature_help(db: &RootDatabase, position: FilePosition) -> Optio
105105 // Stop at multi-line expressions, since the signature of the outer call is not very
106106 // helpful inside them.
107107 if let Some ( expr) = ast:: Expr :: cast ( node. clone ( ) ) {
108- if expr. syntax ( ) . text ( ) . contains_char ( '\n' )
109- && expr. syntax ( ) . kind ( ) != SyntaxKind :: RECORD_EXPR
108+ if ! matches ! ( expr, ast :: Expr :: RecordExpr ( .. ) )
109+ && expr. syntax ( ) . text ( ) . contains_char ( '\n' )
110110 {
111- return None ;
111+ break ;
112112 }
113113 }
114114 }
@@ -122,18 +122,16 @@ fn signature_help_for_call(
122122 token : SyntaxToken ,
123123) -> Option < SignatureHelp > {
124124 // Find the calling expression and its NameRef
125- let mut node = arg_list. syntax ( ) . parent ( ) ? ;
125+ let mut nodes = arg_list. syntax ( ) . ancestors ( ) . skip ( 1 ) ;
126126 let calling_node = loop {
127- if let Some ( callable) = ast:: CallableExpr :: cast ( node . clone ( ) ) {
128- if callable
127+ if let Some ( callable) = ast:: CallableExpr :: cast ( nodes . next ( ) ? ) {
128+ let inside_callable = callable
129129 . arg_list ( )
130- . map_or ( false , |it| it. syntax ( ) . text_range ( ) . contains ( token. text_range ( ) . start ( ) ) )
131- {
130+ . map_or ( false , |it| it. syntax ( ) . text_range ( ) . contains ( token. text_range ( ) . start ( ) ) ) ;
131+ if inside_callable {
132132 break callable;
133133 }
134134 }
135-
136- node = node. parent ( ) ?;
137135 } ;
138136
139137 let ( callable, active_parameter) = callable_for_node ( sema, & calling_node, & token) ?;
@@ -1594,4 +1592,27 @@ impl S {
15941592 "# ] ] ,
15951593 ) ;
15961594 }
1595+
1596+ #[ test]
1597+ fn test_enum_in_nested_method_in_lambda ( ) {
1598+ check (
1599+ r#"
1600+ enum A {
1601+ A,
1602+ B
1603+ }
1604+
1605+ fn bar(_: A) { }
1606+
1607+ fn main() {
1608+ let foo = Foo;
1609+ std::thread::spawn(move || { bar(A:$0) } );
1610+ }
1611+ "# ,
1612+ expect ! [ [ r#"
1613+ fn bar(_: A)
1614+ ^^^^
1615+ "# ] ] ,
1616+ ) ;
1617+ }
15971618}
0 commit comments