File tree Expand file tree Collapse file tree
crates/ide-completion/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -733,7 +733,7 @@ fn path_ref_match(
733733 // FIXME: This might create inconsistent completions where we show a ref match in macro inputs
734734 // as long as nothing was typed yet
735735 if let Some ( ref_mode) = compute_ref_match ( completion, ty) {
736- item. ref_match ( ref_mode, completion. position . offset ) ;
736+ item. ref_match ( ref_mode, completion. source_range ( ) . start ( ) ) ;
737737 }
738738 }
739739}
@@ -2142,6 +2142,53 @@ fn go(world: &WorldSnapshot) { go(w$0) }
21422142 ) ;
21432143 }
21442144
2145+ #[ test]
2146+ fn complete_ref_match_after_keyword_prefix ( ) {
2147+ // About https://github.com/rust-lang/rust-analyzer/issues/15139
2148+ check_kinds (
2149+ r#"
2150+ fn foo(data: &i32) {}
2151+ fn main() {
2152+ let indent = 2i32;
2153+ foo(in$0)
2154+ }
2155+ "# ,
2156+ & [ CompletionItemKind :: SymbolKind ( SymbolKind :: Local ) ] ,
2157+ expect ! [ [ r#"
2158+ [
2159+ CompletionItem {
2160+ label: "indent",
2161+ detail_left: None,
2162+ detail_right: Some(
2163+ "i32",
2164+ ),
2165+ source_range: 65..67,
2166+ delete: 65..67,
2167+ insert: "indent",
2168+ kind: SymbolKind(
2169+ Local,
2170+ ),
2171+ detail: "i32",
2172+ relevance: CompletionRelevance {
2173+ exact_name_match: false,
2174+ type_match: None,
2175+ is_local: true,
2176+ trait_: None,
2177+ is_name_already_imported: false,
2178+ requires_import: false,
2179+ is_private_editable: false,
2180+ postfix_match: None,
2181+ function: None,
2182+ is_skipping_completion: false,
2183+ has_local_inherent_impl: false,
2184+ },
2185+ ref_match: "&@65",
2186+ },
2187+ ]
2188+ "# ] ] ,
2189+ ) ;
2190+ }
2191+
21452192 #[ test]
21462193 fn too_many_arguments ( ) {
21472194 cov_mark:: check!( too_many_arguments) ;
You can’t perform that action at this time.
0 commit comments