Don't return a SourceChange on WillRenameFiles when nothing gets refactored

This commit is contained in:
Lukas Wirth 2021-03-20 13:44:39 +01:00
parent d84912483d
commit a9a7c5cb1f
2 changed files with 7 additions and 8 deletions

View 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(

View 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