@@ -69,10 +69,6 @@ pub(crate) fn complete_postfix(
69
69
}
70
70
}
71
71
72
- if !ctx. config . snippets . is_empty ( ) {
73
- add_custom_postfix_completions ( acc, ctx, & postfix_snippet, & receiver_text) ;
74
- }
75
-
76
72
let try_enum = TryEnum :: from_ty ( & ctx. sema , & receiver_ty. strip_references ( ) ) ;
77
73
if let Some ( try_enum) = & try_enum {
78
74
match try_enum {
@@ -140,6 +136,10 @@ pub(crate) fn complete_postfix(
140
136
None => return ,
141
137
} ;
142
138
139
+ if !ctx. config . snippets . is_empty ( ) {
140
+ add_custom_postfix_completions ( acc, ctx, & postfix_snippet, & receiver_text) ;
141
+ }
142
+
143
143
match try_enum {
144
144
Some ( try_enum) => match try_enum {
145
145
TryEnum :: Result => {
@@ -613,4 +613,25 @@ fn main() {
613
613
r#"fn main() { log::error!("{}", 2+2) }"# ,
614
614
) ;
615
615
}
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
+ }
616
637
}
0 commit comments