fix(lsp): fix import specifiers in file rename changes (#30458)
Some checks are pending
ci / test release macos-x86_64 (push) Blocked by required conditions
ci / test debug windows-x86_64 (push) Blocked by required conditions
ci / test release windows-x86_64 (push) Blocked by required conditions
ci / build libs (push) Blocked by required conditions
ci / pre-build (push) Waiting to run
ci / test debug linux-aarch64 (push) Blocked by required conditions
ci / test release linux-aarch64 (push) Blocked by required conditions
ci / test debug macos-aarch64 (push) Blocked by required conditions
ci / test release macos-aarch64 (push) Blocked by required conditions
ci / bench release linux-x86_64 (push) Blocked by required conditions
ci / lint debug linux-x86_64 (push) Blocked by required conditions
ci / lint debug macos-x86_64 (push) Blocked by required conditions
ci / lint debug windows-x86_64 (push) Blocked by required conditions
ci / test debug linux-x86_64 (push) Blocked by required conditions
ci / test release linux-x86_64 (push) Blocked by required conditions
ci / test debug macos-x86_64 (push) Blocked by required conditions
ci / publish canary (push) Blocked by required conditions

This commit is contained in:
Nayeem Rahman 2025-08-19 21:46:59 +01:00 committed by GitHub
parent dabf9c79b3
commit efdcdf82c9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 104 additions and 2 deletions

View file

@ -108,6 +108,7 @@ use crate::file_fetcher::CreateCliFileFetcherOptions;
use crate::file_fetcher::create_cli_file_fetcher;
use crate::graph_util;
use crate::http_util::HttpClientProvider;
use crate::lsp::analysis::fix_ts_import_changes_for_file_rename;
use crate::lsp::compiler_options::LspCompilerOptionsResolver;
use crate::lsp::config::ConfigWatchedFileType;
use crate::lsp::diagnostics::generate_module_diagnostics;
@ -3889,8 +3890,25 @@ impl Inner {
LspError::internal_error()
}
})?;
changes_with_modules
.extend(changes.into_iter().map(|c| (c, module.clone())));
let changes = fix_ts_import_changes_for_file_rename(
changes,
&rename.new_uri,
&module,
self,
token,
)
.map_err(|err| {
if token.is_cancelled() {
LspError::request_cancelled()
} else {
error!("Unable to fix import changes: {:#}", err);
LspError::internal_error()
}
})?;
if !changes.is_empty() {
changes_with_modules
.extend(changes.into_iter().map(|c| (c, module.clone())));
}
}
}
file_text_changes_to_workspace_edit(&changes_with_modules, self, token)