From d8773908821a17ba160eaccab45b6813048b1abf Mon Sep 17 00:00:00 2001 From: ShuiRuTian <158983297@qq.com> Date: Tue, 12 Jan 2021 00:21:03 +0800 Subject: fix as suggestion. --- crates/rust-analyzer/src/handlers.rs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'crates') diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs index c7b615002..1f21533cb 100644 --- a/crates/rust-analyzer/src/handlers.rs +++ b/crates/rust-analyzer/src/handlers.rs @@ -433,27 +433,23 @@ pub(crate) fn handle_will_rename_files( match (from_path.parent(), to_path.parent()) { (Some(p1), Some(p2)) if p1 == p2 => { if from_path.is_dir() { - // This is a quick implement, try to use will_rename_file code. - // imitate change the older_folder/mod.rs to older_folder/new_folder.rs - // add '/' to end of url -- from `file://path/to/folder` to `file://path/to/folder/` let mut old_folder_name = from_path.file_stem()?.to_str()?.to_string(); old_folder_name.push('/'); let from_with_trailing_slash = from.join(&old_folder_name).ok()?; let imitate_from_url = from_with_trailing_slash.join("mod.rs").ok()?; - let imite_new_file_name = to_path.file_name()?.to_str()?; + let new_file_name = to_path.file_name()?.to_str()?; Some(( snap.url_to_file_id(&imitate_from_url).ok()?, - imite_new_file_name.to_string(), + new_file_name.to_string(), )) } else { let old_name = from_path.file_stem()?.to_str()?; let new_name = to_path.file_stem()?.to_str()?; - if old_name != "mod" && new_name != "mod" { - Some((snap.url_to_file_id(&from).ok()?, new_name.to_string())) - } else { - None + match(old_name,new_name){ + ("mod","mod") =>Some((snap.url_to_file_id(&from).ok()?, new_name.to_string())), + _=>None } } } -- cgit v1.2.3