File tree Expand file tree Collapse file tree 1 file changed +8
-7
lines changed
src/PowerShellEditorServices/Services/TextDocument Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -396,13 +396,14 @@ internal static bool IsValidFunctionName(string name)
396396 {
397397 // Allows us to supply function:varname or varname and get a proper result
398398 string candidate = "function " + name . TrimStart ( '$' ) . TrimStart ( '-' ) + " {}" ;
399- Parser . ParseInput ( candidate , out Token [ ] tokens , out _ ) ;
400- return tokens . Length == 5
401- && tokens [ 0 ] . Kind == TokenKind . Function
402- && tokens [ 1 ] . Kind == TokenKind . Identifier
403- && tokens [ 2 ] . Kind == TokenKind . LCurly
404- && tokens [ 3 ] . Kind == TokenKind . RCurly
405- && tokens [ 4 ] . Kind == TokenKind . EndOfInput ;
399+ Ast ast = Parser . ParseInput ( candidate , out _ , out ParseError [ ] errors ) ;
400+ if ( errors . Length > 0 )
401+ {
402+ return false ;
403+ }
404+
405+ return ( ast . Find ( a => a is FunctionDefinitionAst , false ) as FunctionDefinitionAst ) ?
406+ . Name is not null ;
406407 }
407408}
408409
You can’t perform that action at this time.
0 commit comments