Use mark to check that paths that are too long will not be merged

This commit is contained in:
Lukas Wirth 2020-09-02 19:34:01 +02:00
parent 74186d3ae7
commit 07ff9eeca8

View file

@ -10,6 +10,7 @@ use syntax::{
};
use crate::assist_context::AssistContext;
use test_utils::mark;
/// Determines the containing syntax node in which to insert a `use` statement affecting `position`.
pub(crate) fn find_insert_use_container(
@ -126,6 +127,7 @@ pub fn try_merge_trees(
if merge_behaviour == MergeBehaviour::Last
&& (use_tree_list_is_nested(&lhs_tl) || use_tree_list_is_nested(&rhs_tl))
{
mark::hit!(test_last_merge_too_long);
return None;
}
@ -586,6 +588,17 @@ use std::io;",
)
}
#[test]
fn merge_last_too_long() {
mark::check!(test_last_merge_too_long);
check_last(
"foo::bar",
r"use foo::bar::baz::Qux;",
r"use foo::bar::baz::Qux;
use foo::bar;",
);
}
fn check(
path: &str,
ra_fixture_before: &str,