aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/rust-analyzer/src/handlers.rs28
1 files changed, 14 insertions, 14 deletions
diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs
index 176774a77..480608196 100644
--- a/crates/rust-analyzer/src/handlers.rs
+++ b/crates/rust-analyzer/src/handlers.rs
@@ -435,22 +435,22 @@ pub(crate) fn handle_will_rename_files(
435 if from_path.is_dir() { 435 if from_path.is_dir() {
436 // This is a quick implement, try to use will_rename_file code. 436 // This is a quick implement, try to use will_rename_file code.
437 // imitate change the older_folder/mod.rs to older_folder/new_folder.rs 437 // imitate change the older_folder/mod.rs to older_folder/new_folder.rs
438 let imitate_from_path = from_path.join("mod.rs"); 438 let imitate_from_url = from.join("mod.rs").ok()?;
439 let new_from_url = imitate_from_path.to_str()?; 439 let imite_new_file_name = to_path.file_name()?.to_str()?;
440 let new_from_url = Url::parse(new_from_url).ok()?; 440 Some((
441 441 snap.url_to_file_id(&imitate_from_url).ok()?,
442 let new_folder_name = to_path.file_name()?.to_str()?; 442 imite_new_file_name.to_string(),
443 let mut imite_new_file_name = new_folder_name.to_string(); 443 ))
444 imite_new_file_name.push_str(".rs"); 444 } else {
445 let new_to = from_path.join(imite_new_file_name); 445 let old_name = from_path.file_stem()?;
446 let new_to = new_to.to_str()?; 446 let old_name = old_name.to_str()?;
447
448 Some((snap.url_to_file_id(&new_from_url).ok()?, new_to.to_string()))
449 }
450 else{
451 let new_name = to_path.file_stem()?; 447 let new_name = to_path.file_stem()?;
452 let new_name = new_name.to_str()?; 448 let new_name = new_name.to_str()?;
453 Some((snap.url_to_file_id(&from).ok()?, new_name.to_string())) 449 if old_name != "mod" || new_name != "mod" {
450 Some((snap.url_to_file_id(&from).ok()?, new_name.to_string()))
451 } else {
452 None
453 }
454 } 454 }
455 } 455 }
456 _ => None, 456 _ => None,