From 7cf273a18e7893f2c57bf4430c8962685ed10c09 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Mon, 14 Jun 2021 13:56:33 +0200 Subject: Don't keep a trailing self token in import paths after unmerge_use --- crates/ide_assists/src/handlers/unmerge_use.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'crates/ide_assists') diff --git a/crates/ide_assists/src/handlers/unmerge_use.rs b/crates/ide_assists/src/handlers/unmerge_use.rs index 8d271e056..14e862cd0 100644 --- a/crates/ide_assists/src/handlers/unmerge_use.rs +++ b/crates/ide_assists/src/handlers/unmerge_use.rs @@ -73,7 +73,11 @@ fn resolve_full_path(tree: &ast::UseTree) -> Option { for path in paths { final_path = ast::make::path_concat(path, final_path) } - Some(final_path) + if final_path.segment().map_or(false, |it| it.self_token().is_some()) { + final_path.qualifier() + } else { + Some(final_path) + } } #[cfg(test)] @@ -223,4 +227,14 @@ pub use std::fmt::Display; ", ); } + + #[test] + fn unmerge_use_item_on_self() { + check_assist( + unmerge_use, + r"use std::process::{Command, self$0};", + r"use std::process::{Command}; +use std::process;", + ); + } } -- cgit v1.2.3