diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/rust-analyzer/src/handlers.rs | 14 |
1 files changed, 5 insertions, 9 deletions
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( | |||
433 | match (from_path.parent(), to_path.parent()) { | 433 | match (from_path.parent(), to_path.parent()) { |
434 | (Some(p1), Some(p2)) if p1 == p2 => { | 434 | (Some(p1), Some(p2)) if p1 == p2 => { |
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. | ||
437 | // imitate change the older_folder/mod.rs to older_folder/new_folder.rs | ||
438 | |||
439 | // add '/' to end of url -- from `file://path/to/folder` to `file://path/to/folder/` | 436 | // add '/' to end of url -- from `file://path/to/folder` to `file://path/to/folder/` |
440 | let mut old_folder_name = from_path.file_stem()?.to_str()?.to_string(); | 437 | let mut old_folder_name = from_path.file_stem()?.to_str()?.to_string(); |
441 | old_folder_name.push('/'); | 438 | old_folder_name.push('/'); |
442 | let from_with_trailing_slash = from.join(&old_folder_name).ok()?; | 439 | let from_with_trailing_slash = from.join(&old_folder_name).ok()?; |
443 | 440 | ||
444 | let imitate_from_url = from_with_trailing_slash.join("mod.rs").ok()?; | 441 | let imitate_from_url = from_with_trailing_slash.join("mod.rs").ok()?; |
445 | let imite_new_file_name = to_path.file_name()?.to_str()?; | 442 | let new_file_name = to_path.file_name()?.to_str()?; |
446 | Some(( | 443 | Some(( |
447 | snap.url_to_file_id(&imitate_from_url).ok()?, | 444 | snap.url_to_file_id(&imitate_from_url).ok()?, |
448 | imite_new_file_name.to_string(), | 445 | new_file_name.to_string(), |
449 | )) | 446 | )) |
450 | } else { | 447 | } else { |
451 | let old_name = from_path.file_stem()?.to_str()?; | 448 | let old_name = from_path.file_stem()?.to_str()?; |
452 | let new_name = to_path.file_stem()?.to_str()?; | 449 | let new_name = to_path.file_stem()?.to_str()?; |
453 | if old_name != "mod" && new_name != "mod" { | 450 | match(old_name,new_name){ |
454 | Some((snap.url_to_file_id(&from).ok()?, new_name.to_string())) | 451 | ("mod","mod") =>Some((snap.url_to_file_id(&from).ok()?, new_name.to_string())), |
455 | } else { | 452 | _=>None |
456 | None | ||
457 | } | 453 | } |
458 | } | 454 | } |
459 | } | 455 | } |