Skip to content

Commit 7b11670

Browse files
authored
fix(lsp): silence debug error for 'move to a new file' action (#27780)
1 parent f3c0bbf commit 7b11670

File tree

1 file changed

+28
-13
lines changed

1 file changed

+28
-13
lines changed

cli/lsp/language_server.rs

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1884,7 +1884,7 @@ impl Inner {
18841884
})?;
18851885
let asset_or_doc = self.get_asset_or_document(&action_data.specifier)?;
18861886
let line_index = asset_or_doc.line_index();
1887-
let mut refactor_edit_info = self
1887+
let refactor_edit_info = self
18881888
.ts_server
18891889
.get_edits_for_refactor(
18901890
self.snapshot(),
@@ -1905,19 +1905,34 @@ impl Inner {
19051905
)),
19061906
asset_or_doc.scope().cloned(),
19071907
)
1908-
.await?;
1909-
if kind_suffix == ".rewrite.function.returnType"
1910-
|| kind_suffix == ".move.newFile"
1911-
{
1912-
refactor_edit_info.edits =
1913-
fix_ts_import_changes(&refactor_edit_info.edits, self).map_err(
1914-
|err| {
1915-
error!("Unable to remap changes: {:#}", err);
1916-
LspError::internal_error()
1917-
},
1918-
)?
1908+
.await;
1909+
1910+
match refactor_edit_info {
1911+
Ok(mut refactor_edit_info) => {
1912+
if kind_suffix == ".rewrite.function.returnType"
1913+
|| kind_suffix == ".move.newFile"
1914+
{
1915+
refactor_edit_info.edits =
1916+
fix_ts_import_changes(&refactor_edit_info.edits, self).map_err(
1917+
|err| {
1918+
error!("Unable to remap changes: {:#}", err);
1919+
LspError::internal_error()
1920+
},
1921+
)?
1922+
}
1923+
code_action.edit = refactor_edit_info.to_workspace_edit(self)?;
1924+
}
1925+
Err(err) => {
1926+
// TODO(nayeemrmn): Investigate cause for
1927+
// https://github.com/denoland/deno/issues/27778. Prevent popups for
1928+
// this error for now.
1929+
if kind_suffix == ".move.newFile" {
1930+
lsp_warn!("{:#}", err);
1931+
} else {
1932+
return Err(err);
1933+
}
1934+
}
19191935
}
1920-
code_action.edit = refactor_edit_info.to_workspace_edit(self)?;
19211936
code_action
19221937
} else {
19231938
// The code action doesn't need to be resolved

0 commit comments

Comments
 (0)