Fix Prettier parser values when formatting files with paths (#13666)
Closes https://github.com/zed-industries/zed/issues/13660 Now, as intended, the parser value is passed only if configured in the language settings. Also, allows to format JSONC by default with Prettier and reformats Zed settings. Release Notes: - Fixed Zed Prettier integration always passing parser value for files with paths ([13660](https://github.com/zed-industries/zed/issues/13660))
This commit is contained in:
parent
f1859e3645
commit
e650c0166d
2 changed files with 30 additions and 79 deletions
|
@ -317,11 +317,14 @@ impl Prettier {
|
|||
})
|
||||
.collect();
|
||||
|
||||
let prettier_parser = prettier_settings.parser.as_deref().or_else(|| buffer_language.and_then(|language| language.prettier_parser_name()));
|
||||
let mut prettier_parser = prettier_settings.parser.as_deref();
|
||||
if buffer_path.is_none() {
|
||||
prettier_parser = prettier_parser.or_else(|| buffer_language.and_then(|language| language.prettier_parser_name()));
|
||||
if prettier_parser.is_none() {
|
||||
log::error!("Formatting unsaved file with prettier failed. No prettier parser configured for language {buffer_language:?}");
|
||||
return Err(anyhow!("Cannot determine prettier parser for unsaved file"));
|
||||
}
|
||||
|
||||
if prettier_parser.is_none() && buffer_path.is_none() {
|
||||
log::error!("Formatting unsaved file with prettier failed. No prettier parser configured for language {buffer_language:?}");
|
||||
return Err(anyhow!("Cannot determine prettier parser for unsaved file"));
|
||||
}
|
||||
|
||||
log::debug!(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue