]> git.lizzy.rs Git - rust.git/commitdiff
Don't return a SourceChange on WillRenameFiles when nothing gets refactored
authorLukas Wirth <lukastw97@gmail.com>
Sat, 20 Mar 2021 12:44:39 +0000 (13:44 +0100)
committerLukas Wirth <lukastw97@gmail.com>
Sat, 20 Mar 2021 12:57:58 +0000 (13:57 +0100)
crates/rust-analyzer/src/handlers.rs
crates/rust-analyzer/tests/rust-analyzer/main.rs

index b6f484e5157f74c976a812963beb025c3c06ef61..880fea62209167a6a08734f0cb3727b861d47eea 100644 (file)
@@ -465,8 +465,11 @@ pub(crate) fn handle_will_rename_files(
     source_change.file_system_edits.clear();
     // no collect here because we want to merge text edits on same file ids
     source_change.extend(source_changes.map(|it| it.source_file_edits).flatten());
-    let workspace_edit = to_proto::workspace_edit(&snap, source_change)?;
-    Ok(Some(workspace_edit))
+    if source_change.source_file_edits.is_empty() {
+        Ok(None)
+    } else {
+        to_proto::workspace_edit(&snap, source_change).map(Some)
+    }
 }
 
 pub(crate) fn handle_goto_definition(
index 7545b4a348a16caadae5214f9bcc55de2827853d..19516de7b9aaf649ff4e8155573268c29f20fa73 100644 (file)
@@ -838,9 +838,7 @@ fn main() {}
                 new_uri: base_path.join("src/from_mod/foo.rs").to_str().unwrap().to_string(),
             }],
         },
-        json!({
-          "documentChanges": []
-        }),
+        json!(null),
     );
 
     //rename file from foo.rs to mod.rs
@@ -851,9 +849,7 @@ fn main() {}
                 new_uri: base_path.join("src/to_mod/mod.rs").to_str().unwrap().to_string(),
             }],
         },
-        json!({
-          "documentChanges": []
-        }),
+        json!(null),
     );
 
     //rename same level file