aboutsummaryrefslogtreecommitdiff
path: root/crates/rust-analyzer/src/handlers.rs
diff options
context:
space:
mode:
authorShuiRuTian <[email protected]>2021-01-10 06:10:36 +0000
committerShuiRuTian <[email protected]>2021-01-10 06:10:36 +0000
commit09ed9d044495971c143dc8c9879dd92d3989976f (patch)
tree1cca70c65dbadc2e1d747c67a8557a94f143d3de /crates/rust-analyzer/src/handlers.rs
parent64240a44bec83da2a51a887aac3520110977a7e1 (diff)
fix issue.
Diffstat (limited to 'crates/rust-analyzer/src/handlers.rs')
-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,