@@ -24,8 +24,8 @@ pub(crate) fn complete_fn_param(
2424 ctx : & CompletionContext ,
2525 pattern_ctx : & PatternContext ,
2626) -> Option < ( ) > {
27- let ( param_list, _, param_kind) = match pattern_ctx {
28- PatternContext { param_ctx : Some ( kind) , .. } => kind,
27+ let ( ( param_list, _, param_kind) , impl_ ) = match pattern_ctx {
28+ PatternContext { param_ctx : Some ( kind) , impl_ , .. } => ( kind, impl_ ) ,
2929 _ => return None ,
3030 } ;
3131
@@ -45,7 +45,7 @@ pub(crate) fn complete_fn_param(
4545
4646 match param_kind {
4747 ParamKind :: Function ( function) => {
48- fill_fn_params ( ctx, function, param_list, add_new_item_to_acc) ;
48+ fill_fn_params ( ctx, function, param_list, impl_ , add_new_item_to_acc) ;
4949 }
5050 ParamKind :: Closure ( closure) => {
5151 let stmt_list = closure. syntax ( ) . ancestors ( ) . find_map ( ast:: StmtList :: cast) ?;
@@ -62,6 +62,7 @@ fn fill_fn_params(
6262 ctx : & CompletionContext ,
6363 function : & ast:: Fn ,
6464 param_list : & ast:: ParamList ,
65+ impl_ : & Option < ast:: Impl > ,
6566 mut add_new_item_to_acc : impl FnMut ( & str ) ,
6667) {
6768 let mut file_params = FxHashMap :: default ( ) ;
@@ -104,7 +105,7 @@ fn fill_fn_params(
104105 }
105106 remove_duplicated ( & mut file_params, param_list. params ( ) ) ;
106107 let self_completion_items = [ "self" , "&self" , "mut self" , "&mut self" ] ;
107- if should_add_self_completions ( ctx , param_list ) {
108+ if should_add_self_completions ( param_list , impl_ ) {
108109 self_completion_items. into_iter ( ) . for_each ( |self_item| add_new_item_to_acc ( self_item) ) ;
109110 }
110111
@@ -155,11 +156,10 @@ fn remove_duplicated(
155156 } )
156157}
157158
158- fn should_add_self_completions ( ctx : & CompletionContext , param_list : & ast:: ParamList ) -> bool {
159- let inside_impl = ctx. impl_def . is_some ( ) ;
159+ fn should_add_self_completions ( param_list : & ast:: ParamList , impl_ : & Option < ast:: Impl > ) -> bool {
160160 let no_params = param_list. params ( ) . next ( ) . is_none ( ) && param_list. self_param ( ) . is_none ( ) ;
161161
162- inside_impl && no_params
162+ impl_ . is_some ( ) && no_params
163163}
164164
165165fn comma_wrapper ( ctx : & CompletionContext ) -> Option < ( impl Fn ( & str ) -> String , TextRange ) > {
0 commit comments