diff options
author | Kirill Bulatov <[email protected]> | 2021-01-05 08:34:03 +0000 |
---|---|---|
committer | Kirill Bulatov <[email protected]> | 2021-01-16 18:44:12 +0000 |
commit | db335a1bbf1d1bea2c761f67efb4b49831738e31 (patch) | |
tree | 910963c004c460d2f0c322a0e643947aaf7132b8 /crates/completion/src/item.rs | |
parent | 9a349f280ff1c6d0b57df80aa3d6720474e4b00a (diff) |
Add flyimport completion for trait assoc items
Diffstat (limited to 'crates/completion/src/item.rs')
-rw-r--r-- | crates/completion/src/item.rs | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/crates/completion/src/item.rs b/crates/completion/src/item.rs index 0134ff219..378bd2c70 100644 --- a/crates/completion/src/item.rs +++ b/crates/completion/src/item.rs | |||
@@ -270,6 +270,7 @@ impl CompletionItem { | |||
270 | pub struct ImportEdit { | 270 | pub struct ImportEdit { |
271 | pub import_path: ModPath, | 271 | pub import_path: ModPath, |
272 | pub import_scope: ImportScope, | 272 | pub import_scope: ImportScope, |
273 | pub import_for_trait_assoc_item: bool, | ||
273 | } | 274 | } |
274 | 275 | ||
275 | impl ImportEdit { | 276 | impl ImportEdit { |
@@ -321,17 +322,19 @@ impl Builder { | |||
321 | let mut insert_text = self.insert_text; | 322 | let mut insert_text = self.insert_text; |
322 | 323 | ||
323 | if let Some(import_to_add) = self.import_to_add.as_ref() { | 324 | if let Some(import_to_add) = self.import_to_add.as_ref() { |
324 | let mut import_path_without_last_segment = import_to_add.import_path.to_owned(); | 325 | if import_to_add.import_for_trait_assoc_item { |
325 | let _ = import_path_without_last_segment.segments.pop(); | 326 | lookup = lookup.or_else(|| Some(label.clone())); |
326 | 327 | insert_text = insert_text.or_else(|| Some(label.clone())); | |
327 | if !import_path_without_last_segment.segments.is_empty() { | 328 | label = format!("{} ({})", label, import_to_add.import_path); |
328 | if lookup.is_none() { | 329 | } else { |
329 | lookup = Some(label.clone()); | 330 | let mut import_path_without_last_segment = import_to_add.import_path.to_owned(); |
330 | } | 331 | let _ = import_path_without_last_segment.segments.pop(); |
331 | if insert_text.is_none() { | 332 | |
332 | insert_text = Some(label.clone()); | 333 | if !import_path_without_last_segment.segments.is_empty() { |
334 | lookup = lookup.or_else(|| Some(label.clone())); | ||
335 | insert_text = insert_text.or_else(|| Some(label.clone())); | ||
336 | label = format!("{}::{}", import_path_without_last_segment, label); | ||
333 | } | 337 | } |
334 | label = format!("{}::{}", import_path_without_last_segment, label); | ||
335 | } | 338 | } |
336 | } | 339 | } |
337 | 340 | ||