Fix issue where renaming a file would not update imports in related files if they are not open (#36681)

Closes #34445

Now we open a multi-buffer consisting of buffers that have updated,
renamed file imports.

Only local is handled, for now.

Release Notes:

- Fixed an issue where renaming a file would not update imports in
related files if they are not already open.
This commit is contained in:
Smit Barmase 2025-08-21 20:19:17 +05:30 committed by GitHub
parent d9ea97ee9c
commit 697a39c251
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 87 additions and 11 deletions

View file

@ -8762,7 +8762,7 @@ impl LspStore {
(root_path.join(&old_path), root_path.join(&new_path))
};
Self::will_rename_entry(
let _transaction = Self::will_rename_entry(
this.downgrade(),
worktree_id,
&old_abs_path,
@ -9224,7 +9224,7 @@ impl LspStore {
new_path: &Path,
is_dir: bool,
cx: AsyncApp,
) -> Task<()> {
) -> Task<ProjectTransaction> {
let old_uri = lsp::Url::from_file_path(old_path).ok().map(String::from);
let new_uri = lsp::Url::from_file_path(new_path).ok().map(String::from);
cx.spawn(async move |cx| {
@ -9257,7 +9257,7 @@ impl LspStore {
.log_err()
.flatten()?;
LocalLspStore::deserialize_workspace_edit(
let transaction = LocalLspStore::deserialize_workspace_edit(
this.upgrade()?,
edit,
false,
@ -9265,8 +9265,8 @@ impl LspStore {
cx,
)
.await
.ok();
Some(())
.ok()?;
Some(transaction)
}
});
tasks.push(apply_edit);
@ -9276,11 +9276,17 @@ impl LspStore {
})
.ok()
.flatten();
let mut merged_transaction = ProjectTransaction::default();
for task in tasks {
// Await on tasks sequentially so that the order of application of edits is deterministic
// (at least with regards to the order of registration of language servers)
task.await;
if let Some(transaction) = task.await {
for (buffer, buffer_transaction) in transaction.0 {
merged_transaction.0.insert(buffer, buffer_transaction);
}
}
}
merged_transaction
})
}