diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2024-08-02 15:52:48 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-02 13:52:48 +0000 |
commit | 0da81205d57e947e82aa02206f8ba6822c624ebc (patch) | |
tree | 4472cc6281aca813adc3c2a06321701ea3c3008f /cli/lsp | |
parent | 2aad92c30b327b9db352e8a2c024671205eed9f6 (diff) |
feat(unstable/fmt): move yaml formatting behind unstable flag (#24848)
This moves YAML formatting behind an unstable flag for Deno 1.46. This
will make it opt-in to start and then we can remove the flag to make it
on by default in version of Deno after that.
This can be specified by doing `deno fmt --unstable-yaml` or by
specifying the following in a deno.json file:
```json
{
"unstable": ["fmt-yaml"]
}
```
Diffstat (limited to 'cli/lsp')
-rw-r--r-- | cli/lsp/language_server.rs | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/cli/lsp/language_server.rs b/cli/lsp/language_server.rs index 62cbd58dd..314c9ec14 100644 --- a/cli/lsp/language_server.rs +++ b/cli/lsp/language_server.rs @@ -92,6 +92,7 @@ use crate::args::CaData; use crate::args::CacheSetting; use crate::args::CliOptions; use crate::args::Flags; +use crate::args::UnstableFmtOptions; use crate::factory::CliFactory; use crate::file_fetcher::FileFetcher; use crate::graph_util; @@ -1361,6 +1362,16 @@ impl Inner { .clone(); fmt_options.use_tabs = Some(!params.options.insert_spaces); fmt_options.indent_width = Some(params.options.tab_size as u8); + let maybe_workspace = self + .config + .tree + .data_for_specifier(&specifier) + .map(|d| &d.member_dir.workspace); + let unstable_options = UnstableFmtOptions { + yaml: maybe_workspace + .map(|w| w.has_unstable("fmt-yaml")) + .unwrap_or(false), + }; let document = document.clone(); move || { let format_result = match document.maybe_parsed_source() { @@ -1378,7 +1389,12 @@ impl Inner { .map(|ext| file_path.with_extension(ext)) .unwrap_or(file_path); // it's not a js/ts file, so attempt to format its contents - format_file(&file_path, document.content(), &fmt_options) + format_file( + &file_path, + document.content(), + &fmt_options, + &unstable_options, + ) } }; match format_result { |