diff options
author | Andrea Pretto <[email protected]> | 2019-04-21 22:55:47 +0100 |
---|---|---|
committer | Andrea Pretto <[email protected]> | 2019-04-21 23:48:43 +0100 |
commit | 200032852be0c66b978c875a8edf0eca1f08b901 (patch) | |
tree | 11d45b4470c104f44b237540164bef54cdb55cd9 /crates/ra_ide_api | |
parent | 914421495835380b96e0016763fda6eff31a8179 (diff) |
complete_import: prevent panic when the anchor is the completion source range
(fix rebase mess)
Please enter the commit message for your changes. Lines starting
Diffstat (limited to 'crates/ra_ide_api')
-rw-r--r-- | crates/ra_ide_api/src/completion/complete_scope.rs | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/crates/ra_ide_api/src/completion/complete_scope.rs b/crates/ra_ide_api/src/completion/complete_scope.rs index 63d475823..5bd5376c9 100644 --- a/crates/ra_ide_api/src/completion/complete_scope.rs +++ b/crates/ra_ide_api/src/completion/complete_scope.rs | |||
@@ -23,13 +23,23 @@ pub(super) fn complete_scope(acc: &mut Completions, ctx: &CompletionContext) { | |||
23 | ); | 23 | ); |
24 | builder.finish() | 24 | builder.finish() |
25 | }; | 25 | }; |
26 | CompletionItem::new( | 26 | |
27 | CompletionKind::Reference, | 27 | // Hack: copied this check form conv.rs beacause auto import can produce edits |
28 | ctx.source_range(), | 28 | // that invalidate assert in conv_with. |
29 | build_import_label(&name, &path), | 29 | if edit |
30 | ) | 30 | .as_atoms() |
31 | .text_edit(edit) | 31 | .iter() |
32 | .add_to(acc) | 32 | .filter(|atom| !ctx.source_range().is_subrange(&atom.delete)) |
33 | .all(|atom| ctx.source_range().intersection(&atom.delete).is_none()) | ||
34 | { | ||
35 | CompletionItem::new( | ||
36 | CompletionKind::Reference, | ||
37 | ctx.source_range(), | ||
38 | build_import_label(&name, &path), | ||
39 | ) | ||
40 | .text_edit(edit) | ||
41 | .add_to(acc); | ||
42 | } | ||
33 | }); | 43 | }); |
34 | } | 44 | } |
35 | } | 45 | } |