Skip to content

Commit

Permalink
fix(lsp): pass fmt options to completion requests (denoland#20184)
Browse files Browse the repository at this point in the history
  • Loading branch information
nayeemrmn authored and littledivy committed Aug 21, 2023
1 parent 7f8ceeb commit 98165dc
Show file tree
Hide file tree
Showing 4 changed files with 213 additions and 19 deletions.
16 changes: 14 additions & 2 deletions cli/lsp/language_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ use super::text;
use super::tsc;
use super::tsc::Assets;
use super::tsc::AssetsSnapshot;
use super::tsc::GetCompletionDetailsArgs;
use super::tsc::TsServer;
use super::urls;
use super::urls::LspClientUrl;
Expand Down Expand Up @@ -1899,6 +1900,7 @@ impl Inner {
line_index.offset_tsc(diagnostic.range.start)?
..line_index.offset_tsc(diagnostic.range.end)?,
codes,
(&self.fmt_options.options).into(),
)
.await;
for action in actions {
Expand Down Expand Up @@ -2007,7 +2009,11 @@ impl Inner {
})?;
let combined_code_actions = self
.ts_server
.get_combined_code_fix(self.snapshot(), &code_action_data)
.get_combined_code_fix(
self.snapshot(),
&code_action_data,
(&self.fmt_options.options).into(),
)
.await?;
if combined_code_actions.commands.is_some() {
error!("Deno does not support code actions with commands.");
Expand Down Expand Up @@ -2047,6 +2053,7 @@ impl Inner {
.get_edits_for_refactor(
self.snapshot(),
action_data.specifier,
(&self.fmt_options.options).into(),
line_index.offset_tsc(action_data.range.start)?
..line_index.offset_tsc(action_data.range.end)?,
action_data.refactor_name,
Expand Down Expand Up @@ -2402,6 +2409,7 @@ impl Inner {
trigger_character,
trigger_kind,
},
(&self.fmt_options.options).into(),
)
.await;

Expand Down Expand Up @@ -2436,9 +2444,13 @@ impl Inner {
})?;
if let Some(data) = &data.tsc {
let specifier = &data.specifier;
let args = GetCompletionDetailsArgs {
format_code_settings: Some((&self.fmt_options.options).into()),
..data.into()
};
let result = self
.ts_server
.get_completion_details(self.snapshot(), data.into())
.get_completion_details(self.snapshot(), args)
.await;
match result {
Ok(maybe_completion_info) => {
Expand Down
Loading

0 comments on commit 98165dc

Please sign in to comment.