mirror of
https://github.com/alacritty/alacritty.git
synced 2024-11-25 14:05:41 -05:00
Fix deserialization of old decorations values
The deprecated `window.decoration` values `true` and `false` were using the `visit_bool` visitor for serde. However, only the `str` visitor was ever called. To print the correct deprecation notice, the bool visitor has been removed and the warning has been added for the `"true"` and `"false"` str visitor.
This commit is contained in:
parent
5e97fcbea4
commit
93837110aa
1 changed files with 26 additions and 20 deletions
|
@ -279,29 +279,27 @@ impl<'de> Deserialize<'de> for Decorations {
|
|||
f.write_str("Some subset of full|transparent|buttonless|none")
|
||||
}
|
||||
|
||||
fn visit_bool<E>(self, value: bool) -> ::std::result::Result<Decorations, E>
|
||||
where E: de::Error
|
||||
{
|
||||
if value {
|
||||
eprintln!("deprecated decorations boolean value, use one of \
|
||||
default|transparent|buttonless|none instead; Falling back to \"full\"");
|
||||
Ok(Decorations::Full)
|
||||
} else {
|
||||
eprintln!("deprecated decorations boolean value, use one of \
|
||||
default|transparent|buttonless|none instead; Falling back to \"none\"");
|
||||
Ok(Decorations::None)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
fn visit_str<E>(self, value: &str) -> ::std::result::Result<Decorations, E>
|
||||
where E: de::Error
|
||||
{
|
||||
match value {
|
||||
match value.to_lowercase().as_str() {
|
||||
"transparent" => Ok(Decorations::Transparent),
|
||||
"buttonless" => Ok(Decorations::Buttonless),
|
||||
"none" => Ok(Decorations::None),
|
||||
"full" => Ok(Decorations::Full),
|
||||
"true" => {
|
||||
eprintln!("deprecated decorations boolean value, \
|
||||
use one of transparent|buttonless|none|full instead; \
|
||||
Falling back to \"full\"");
|
||||
Ok(Decorations::Full)
|
||||
},
|
||||
"false" => {
|
||||
eprintln!("deprecated decorations boolean value, \
|
||||
use one of transparent|buttonless|none|full instead; \
|
||||
Falling back to \"none\"");
|
||||
Ok(Decorations::None)
|
||||
},
|
||||
_ => {
|
||||
eprintln!("invalid decorations value: {}; Using default value", value);
|
||||
Ok(Decorations::Full)
|
||||
|
@ -316,14 +314,22 @@ impl<'de> Deserialize<'de> for Decorations {
|
|||
match value.to_lowercase().as_str() {
|
||||
"none" => Ok(Decorations::None),
|
||||
"full" => Ok(Decorations::Full),
|
||||
"transparent" => {
|
||||
"true" => {
|
||||
eprintln!("deprecated decorations boolean value, \
|
||||
use one of none|full instead; \
|
||||
Falling back to \"full\"");
|
||||
Ok(Decorations::Full)
|
||||
},
|
||||
"false" => {
|
||||
eprintln!("deprecated decorations boolean value, \
|
||||
use one of none|full instead; \
|
||||
Falling back to \"none\"");
|
||||
Ok(Decorations::None)
|
||||
},
|
||||
"transparent" | "buttonless" => {
|
||||
eprintln!("macos-only decorations value: {}; Using default value", value);
|
||||
Ok(Decorations::Full)
|
||||
},
|
||||
"buttonless" => {
|
||||
eprintln!("macos-only decorations value: {}; Using default value", value);
|
||||
Ok(Decorations::Full)
|
||||
}
|
||||
_ => {
|
||||
eprintln!("invalid decorations value: {}; Using default value", value);
|
||||
Ok(Decorations::Full)
|
||||
|
|
Loading…
Reference in a new issue