@@ -549,60 +549,55 @@ impl<'a> CompletionContext<'a> {
549
549
550
550
clauses_with_score. sort_by ( |( _, score_a) , ( _, score_b) | score_b. cmp ( score_a) ) ;
551
551
clauses_with_score
552
- . iter ( )
553
- . filter ( |( _, score) | * score > 0 )
554
- . next ( )
552
+ . iter ( ) . find ( |( _, score) | * score > 0 )
555
553
. map ( |c| c. 0 . clone ( ) )
556
554
}
557
555
558
556
fn get_info_from_error_node_child ( & mut self , node : tree_sitter:: Node < ' a > ) {
559
557
let mut first_sibling = self . get_first_sibling ( node) ;
560
558
561
559
if let Some ( clause) = self . wrapping_clause_type . as_ref ( ) {
562
- match clause {
563
- WrappingClause :: Insert => {
564
- while let Some ( sib) = first_sibling. next_sibling ( ) {
565
- match sib. kind ( ) {
566
- "object_reference" => {
567
- if let Some ( NodeText :: Original ( txt) ) =
568
- self . get_ts_node_content ( & sib)
569
- {
570
- let mut iter = txt. split ( '.' ) . rev ( ) ;
571
- let table = iter. next ( ) . unwrap ( ) . to_string ( ) ;
572
- let schema = iter. next ( ) . map ( |s| s. to_string ( ) ) ;
573
- self . mentioned_relations
574
- . entry ( schema)
575
- . and_modify ( |s| {
576
- s. insert ( table. clone ( ) ) ;
577
- } )
578
- . or_insert ( HashSet :: from ( [ table] ) ) ;
579
- }
560
+ if clause == & WrappingClause :: Insert {
561
+ while let Some ( sib) = first_sibling. next_sibling ( ) {
562
+ match sib. kind ( ) {
563
+ "object_reference" => {
564
+ if let Some ( NodeText :: Original ( txt) ) =
565
+ self . get_ts_node_content ( & sib)
566
+ {
567
+ let mut iter = txt. split ( '.' ) . rev ( ) ;
568
+ let table = iter. next ( ) . unwrap ( ) . to_string ( ) ;
569
+ let schema = iter. next ( ) . map ( |s| s. to_string ( ) ) ;
570
+ self . mentioned_relations
571
+ . entry ( schema)
572
+ . and_modify ( |s| {
573
+ s. insert ( table. clone ( ) ) ;
574
+ } )
575
+ . or_insert ( HashSet :: from ( [ table] ) ) ;
580
576
}
581
- "column" => {
582
- if let Some ( NodeText :: Original ( txt ) ) =
583
- self . get_ts_node_content ( & sib )
584
- {
585
- let entry = MentionedColumn {
586
- column : txt ,
587
- alias : None ,
588
- } ;
589
-
590
- self . mentioned_columns
591
- . entry ( Some ( WrappingClause :: Insert ) )
592
- . and_modify ( |s| {
593
- s . insert ( entry . clone ( ) ) ;
594
- } )
595
- . or_insert ( HashSet :: from ( [ entry ] ) ) ;
596
- }
577
+ }
578
+ "column" => {
579
+ if let Some ( NodeText :: Original ( txt ) ) =
580
+ self . get_ts_node_content ( & sib )
581
+ {
582
+ let entry = MentionedColumn {
583
+ column : txt ,
584
+ alias : None ,
585
+ } ;
586
+
587
+ self . mentioned_columns
588
+ . entry ( Some ( WrappingClause :: Insert ) )
589
+ . and_modify ( |s| {
590
+ s . insert ( entry . clone ( ) ) ;
591
+ } )
592
+ . or_insert ( HashSet :: from ( [ entry ] ) ) ;
597
593
}
598
-
599
- _ => { }
600
594
}
601
595
602
- first_sibling = sib ;
596
+ _ => { }
603
597
}
598
+
599
+ first_sibling = sib;
604
600
}
605
- _ => { }
606
601
}
607
602
}
608
603
}
@@ -654,7 +649,7 @@ impl<'a> CompletionContext<'a> {
654
649
self . node_under_cursor . as_ref ( ) . is_some_and ( |under_cursor| {
655
650
match under_cursor {
656
651
NodeUnderCursor :: TsNode ( node) => {
657
- let mut current = node. clone ( ) ;
652
+ let mut current = * node;
658
653
659
654
// move up to the parent until we're at top OR we have a prev sibling
660
655
while current. prev_sibling ( ) . is_none ( ) && current. parent ( ) . is_some ( ) {
0 commit comments