@@ -45,7 +45,7 @@ use crate::{
4545 union_literal:: render_union_literal,
4646 RenderContext ,
4747 } ,
48- CompletionContext , CompletionItem , CompletionItemKind , CompletionRelevance ,
48+ CompletionContext , CompletionItem , CompletionItemKind ,
4949} ;
5050
5151/// Represents an in-progress set of completions being built.
@@ -600,31 +600,30 @@ impl Completions {
600600 /// fn with param that returns itself
601601 pub ( crate ) fn sort_new_first ( & mut self ) {
602602 // ToDo: Ensure these fn returns Self
603- fn creates_self ( item : & CompletionItem ) -> bool {
603+ fn maybe_new ( item : & CompletionItem ) -> bool {
604604 item. detail . as_ref ( ) . map ( |d| d. starts_with ( "fn() -> " ) ) . unwrap_or_default ( )
605605 }
606- fn creates_self_given_args ( item : & CompletionItem ) -> bool {
606+ fn maybe_new_with_args ( item : & CompletionItem ) -> bool {
607607 item. detail
608608 . as_ref ( )
609609 . map ( |d| d. starts_with ( "fn(" ) && d. contains ( "->" ) && !d. contains ( "&self" ) )
610610 . unwrap_or_default ( )
611611 }
612612
613+ fn maybe_builder ( item : & CompletionItem ) -> bool {
614+ item. detail
615+ . as_ref ( )
616+ . map ( |d| d. starts_with ( "fn() -> " ) && d. contains ( "Builder" ) )
617+ . unwrap_or_default ( )
618+ }
619+
613620 for item in self . buf . iter_mut ( ) {
614- if creates_self ( & item) {
615- //item.sort_text = Some(format!("{0:08x}", 0));
616- item. relevance = CompletionRelevance {
617- exact_name_match : true ,
618- is_definite : true ,
619- ..Default :: default ( )
620- } ;
621- } else if creates_self_given_args ( & item) {
622- //item.sort_text = Some(format!("{0:08x}", 1));
623- item. relevance = CompletionRelevance {
624- exact_name_match : true ,
625- is_local : true ,
626- ..Default :: default ( )
627- } ;
621+ if maybe_new ( & item) {
622+ item. bump_relevance_by ( 30 ) ;
623+ } else if maybe_builder ( & item) {
624+ item. bump_relevance_by ( 20 ) ;
625+ } else if maybe_new_with_args ( & item) {
626+ item. bump_relevance_by ( 10 ) ;
628627 }
629628 }
630629 }
0 commit comments