diff options
author | ShuiRuTian <[email protected]> | 2021-01-10 06:10:36 +0000 |
---|---|---|
committer | ShuiRuTian <[email protected]> | 2021-01-10 06:10:36 +0000 |
commit | 09ed9d044495971c143dc8c9879dd92d3989976f (patch) | |
tree | 1cca70c65dbadc2e1d747c67a8557a94f143d3de | |
parent | 64240a44bec83da2a51a887aac3520110977a7e1 (diff) |
fix issue.
-rw-r--r-- | crates/rust-analyzer/src/handlers.rs | 28 | ||||
-rw-r--r-- | editors/code/src/client.ts | 7 |
2 files changed, 21 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, |
diff --git a/editors/code/src/client.ts b/editors/code/src/client.ts index 2a8f2deb4..fb8cd4873 100644 --- a/editors/code/src/client.ts +++ b/editors/code/src/client.ts | |||
@@ -58,6 +58,13 @@ export function createClient(serverPath: string, cwd: string, extraEnv: Env): lc | |||
58 | // 2. filter some change in here. | 58 | // 2. filter some change in here. |
59 | // 2.1 rename from or to `mod.rs` should be special. | 59 | // 2.1 rename from or to `mod.rs` should be special. |
60 | // 2.2 not all folder change should be cared, only those have files with ".rs" postfix. | 60 | // 2.2 not all folder change should be cared, only those have files with ".rs" postfix. |
61 | let newFiles = data.files.map((file)=>{ | ||
62 | const isFolder = !file.oldUri.path.endsWith(".rs"); | ||
63 | return !isFolder ? file : { | ||
64 | oldUri:vscode.Uri.file(file.oldUri.path+'/'), | ||
65 | newUri:vscode.Uri.file(file.newUri.path+'/') | ||
66 | }}); | ||
67 | data = {...data, files:newFiles}; | ||
61 | return next(data); | 68 | return next(data); |
62 | } | 69 | } |
63 | } | 70 | } |