@@ -69,10 +69,6 @@ pub(crate) fn complete_postfix(
6969 }
7070 }
7171
72- if !ctx. config . snippets . is_empty ( ) {
73- add_custom_postfix_completions ( acc, ctx, & postfix_snippet, & receiver_text) ;
74- }
75-
7672 let try_enum = TryEnum :: from_ty ( & ctx. sema , & receiver_ty. strip_references ( ) ) ;
7773 if let Some ( try_enum) = & try_enum {
7874 match try_enum {
@@ -140,6 +136,10 @@ pub(crate) fn complete_postfix(
140136 None => return ,
141137 } ;
142138
139+ if !ctx. config . snippets . is_empty ( ) {
140+ add_custom_postfix_completions ( acc, ctx, & postfix_snippet, & receiver_text) ;
141+ }
142+
143143 match try_enum {
144144 Some ( try_enum) => match try_enum {
145145 TryEnum :: Result => {
@@ -613,4 +613,25 @@ fn main() {
613613 r#"fn main() { log::error!("{}", 2+2) }"# ,
614614 ) ;
615615 }
616+
617+ #[ test]
618+ fn postfix_custom_snippets_completion_for_references ( ) {
619+ check_edit_with_config (
620+ CompletionConfig {
621+ snippets : vec ! [ Snippet :: new(
622+ & [ ] ,
623+ & [ "ok" . into( ) ] ,
624+ & [ "Ok(${receiver})" . into( ) ] ,
625+ "" ,
626+ & [ ] ,
627+ crate :: SnippetScope :: Expr ,
628+ )
629+ . unwrap( ) ] ,
630+ ..TEST_CONFIG
631+ } ,
632+ "ok" ,
633+ r#"fn main() { &&42.$0 }"# ,
634+ r#"fn main() { Ok(&&42) }"# ,
635+ ) ;
636+ }
616637}
0 commit comments