mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-03 07:04:49 +00:00
Add a new config to allow renaming of non-local items
With #15656 we started disallowing renaming of non-local items. Although this makes sense there are some false positives that impacted users' workflows. So this config aims to mitigate this by giving users the liberty to disable this feature.
This commit is contained in:
parent
5b62ebc23f
commit
9bd9a17ce5
8 changed files with 65 additions and 17 deletions
|
@ -494,6 +494,9 @@ config_data! {
|
|||
/// Exclude imports from find-all-references.
|
||||
references_excludeImports: bool = "false",
|
||||
|
||||
/// Allow renaming of items not belonging to any workspace crates.
|
||||
renameExternalItems_enable : bool = "false",
|
||||
|
||||
/// Command to be executed instead of 'cargo' for runnables.
|
||||
runnables_command: Option<String> = "null",
|
||||
/// Additional arguments to be passed to cargo for runnables such as
|
||||
|
@ -1739,6 +1742,10 @@ impl Config {
|
|||
self.data.typing_autoClosingAngleBrackets_enable
|
||||
}
|
||||
|
||||
pub fn rename(&self) -> bool {
|
||||
self.data.renameExternalItems_enable
|
||||
}
|
||||
|
||||
// FIXME: VSCode seems to work wrong sometimes, see https://github.com/microsoft/vscode/issues/193124
|
||||
// hence, distinguish it for now.
|
||||
pub fn is_visual_studio_code(&self) -> bool {
|
||||
|
|
|
@ -1017,8 +1017,10 @@ pub(crate) fn handle_rename(
|
|||
let _p = profile::span("handle_rename");
|
||||
let position = from_proto::file_position(&snap, params.text_document_position)?;
|
||||
|
||||
let mut change =
|
||||
snap.analysis.rename(position, ¶ms.new_name)?.map_err(to_proto::rename_error)?;
|
||||
let mut change = snap
|
||||
.analysis
|
||||
.rename(position, ¶ms.new_name, snap.config.rename())?
|
||||
.map_err(to_proto::rename_error)?;
|
||||
|
||||
// this is kind of a hack to prevent double edits from happening when moving files
|
||||
// When a module gets renamed by renaming the mod declaration this causes the file to move
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue