aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/assists/src/utils/insert_use.rs71
1 files changed, 68 insertions, 3 deletions
diff --git a/crates/assists/src/utils/insert_use.rs b/crates/assists/src/utils/insert_use.rs
index 8ee5e0c9c..8563b16ab 100644
--- a/crates/assists/src/utils/insert_use.rs
+++ b/crates/assists/src/utils/insert_use.rs
@@ -114,8 +114,7 @@ pub fn try_merge_trees(
114 let lhs_tl = lhs.use_tree_list()?; 114 let lhs_tl = lhs.use_tree_list()?;
115 let rhs_tl = rhs.use_tree_list()?; 115 let rhs_tl = rhs.use_tree_list()?;
116 116
117 // if we are only allowed to merge the last level check if the paths are only one level deep 117 // if we are only allowed to merge the last level check if the split off paths are only one level deep
118 // FIXME: This shouldn't work yet i think
119 if merge_behaviour == MergeBehaviour::Last && use_tree_list_is_nested(&lhs_tl) 118 if merge_behaviour == MergeBehaviour::Last && use_tree_list_is_nested(&lhs_tl)
120 || use_tree_list_is_nested(&rhs_tl) 119 || use_tree_list_is_nested(&rhs_tl)
121 { 120 {
@@ -463,7 +462,7 @@ use std::io;",
463 } 462 }
464 463
465 #[test] 464 #[test]
466 fn merges_groups2() { 465 fn merges_groups_full() {
467 check_full( 466 check_full(
468 "std::io", 467 "std::io",
469 r"use std::fmt::{Result, Display};", 468 r"use std::fmt::{Result, Display};",
@@ -472,6 +471,61 @@ use std::io;",
472 } 471 }
473 472
474 #[test] 473 #[test]
474 fn merges_groups_long_full() {
475 check_full(
476 "std::foo::bar::Baz",
477 r"use std::foo::bar::Qux;",
478 r"use std::foo::bar::{Baz, Qux};",
479 )
480 }
481
482 #[test]
483 fn merges_groups_long_last() {
484 check_last(
485 "std::foo::bar::Baz",
486 r"use std::foo::bar::Qux;",
487 r"use std::foo::bar::{Baz, Qux};",
488 )
489 }
490
491 #[test]
492 fn merges_groups_long_full_list() {
493 check_full(
494 "std::foo::bar::Baz",
495 r"use std::foo::bar::{Qux, Quux};",
496 r"use std::foo::bar::{Baz, Quux, Qux};",
497 )
498 }
499
500 #[test]
501 fn merges_groups_long_last_list() {
502 check_last(
503 "std::foo::bar::Baz",
504 r"use std::foo::bar::{Qux, Quux};",
505 r"use std::foo::bar::{Baz, Quux, Qux};",
506 )
507 }
508
509 #[test]
510 fn merges_groups_long_full_nested() {
511 check_full(
512 "std::foo::bar::Baz",
513 r"use std::foo::bar::{Qux, quux::{Fez, Fizz}};",
514 r"use std::foo::bar::{Baz, quux::{Fez, Fizz}, Qux};",
515 )
516 }
517
518 #[test]
519 fn merges_groups_long_last_nested() {
520 check_last(
521 "std::foo::bar::Baz",
522 r"use std::foo::bar::{Qux, quux::{Fez, Fizz}};",
523 r"use std::foo::bar::Baz;
524use std::foo::bar::{quux::{Fez, Fizz}, Qux};",
525 )
526 }
527
528 #[test]
475 fn skip_merges_groups_pub() { 529 fn skip_merges_groups_pub() {
476 check_full( 530 check_full(
477 "std::io", 531 "std::io",
@@ -481,6 +535,17 @@ use std::io;",
481 ) 535 )
482 } 536 }
483 537
538 // should this be a thing?
539 #[test]
540 fn split_merge() {
541 check_last(
542 "std::fmt::Result",
543 r"use std::{fmt, io};",
544 r"use std::fmt::Result;
545use std::io;",
546 )
547 }
548
484 #[test] 549 #[test]
485 fn merges_groups_self() { 550 fn merges_groups_self() {
486 check_full("std::fmt::Debug", r"use std::fmt;", r"use std::fmt::{self, Debug};") 551 check_full("std::fmt::Debug", r"use std::fmt;", r"use std::fmt::{self, Debug};")