@@ -45,7 +45,7 @@ use crate::{
4545 union_literal:: render_union_literal,
4646 RenderContext ,
4747 } ,
48- CompletionContext , CompletionItem , CompletionItemKind ,
48+ CompletionContext , CompletionItem , CompletionItemKind , CompletionRelevance ,
4949} ;
5050
5151/// Represents an in-progress set of completions being built.
@@ -600,29 +600,33 @@ 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 ) -> Option < bool > {
604- item. detail . as_ref ( ) . filter ( |d| d. starts_with ( "fn() -> " ) ) . map ( |_| false )
603+ fn creates_self ( item : & CompletionItem ) -> bool {
604+ item. detail . as_ref ( ) . map ( |d| d. starts_with ( "fn() -> " ) ) . unwrap_or_default ( )
605605 }
606- fn creates_self_given_args ( item : & CompletionItem ) -> Option < bool > {
606+ fn creates_self_given_args ( item : & CompletionItem ) -> bool {
607607 item. detail
608608 . as_ref ( )
609- . filter ( |d| d. starts_with ( "fn(" ) && d. contains ( "->" ) && !d. contains ( "&self" ) )
610- . map ( |_| false )
609+ . map ( |d| d. starts_with ( "fn(" ) && d. contains ( "->" ) && !d. contains ( "&self" ) )
610+ . unwrap_or_default ( )
611611 }
612612
613613 for item in self . buf . iter_mut ( ) {
614- if creates_self ( & item) == Some ( true ) {
615- item. sort_text = Some ( format ! ( "{0:08x}" , 0 ) ) ;
616- } else if creates_self_given_args ( & item) == Some ( true ) {
617- item. sort_text = Some ( format ! ( "{0:08x}" , 1 ) ) ;
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+ } ;
618628 }
619629 }
620-
621- self . buf . sort_by ( |a, b| {
622- creates_self ( b)
623- . cmp ( & creates_self ( a) )
624- . then ( creates_self_given_args ( b) . cmp ( & creates_self_given_args ( a) ) )
625- } ) ;
626630 }
627631}
628632
0 commit comments