File tree Expand file tree Collapse file tree 2 files changed +23
-2
lines changed
crates/ide/src/completion Expand file tree Collapse file tree 2 files changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -267,6 +267,26 @@ fn quux() { <|> }
267
267
) ;
268
268
}
269
269
270
+ /// Regression test for issue #6091.
271
+ #[ test]
272
+ fn correctly_completes_module_items_prefixed_with_underscore ( ) {
273
+ check_edit (
274
+ "_alpha" ,
275
+ r#"
276
+ fn main() {
277
+ _<|>
278
+ }
279
+ fn _alpha() {}
280
+ "# ,
281
+ r#"
282
+ fn main() {
283
+ _alpha()$0
284
+ }
285
+ fn _alpha() {}
286
+ "# ,
287
+ )
288
+ }
289
+
270
290
#[ test]
271
291
fn completes_extern_prelude ( ) {
272
292
check (
Original file line number Diff line number Diff line change @@ -221,10 +221,11 @@ impl<'a> CompletionContext<'a> {
221
221
Some ( ctx)
222
222
}
223
223
224
- // The range of the identifier that is being completed.
224
+ /// The range of the identifier that is being completed.
225
225
pub ( crate ) fn source_range ( & self ) -> TextRange {
226
226
// check kind of macro-expanded token, but use range of original token
227
- if self . token . kind ( ) == IDENT || self . token . kind ( ) . is_keyword ( ) {
227
+ let kind = self . token . kind ( ) ;
228
+ if kind == IDENT || kind == UNDERSCORE || kind. is_keyword ( ) {
228
229
mark:: hit!( completes_if_prefix_is_keyword) ;
229
230
self . original_token . text_range ( )
230
231
} else {
You can’t perform that action at this time.
0 commit comments