Revert "Basic feature flag implementation"

This commit is contained in:
Mikayla Maki 2022-08-22 13:54:18 -07:00 committed by GitHub
parent 1b414b698f
commit b6785c5624
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 18 additions and 29 deletions

View file

@ -10,7 +10,6 @@ use schemars::{
};
use serde::Deserialize;
use serde_json::{value::RawValue, Value};
use util::ResultExt;
#[derive(Deserialize, Default, Clone, JsonSchema)]
#[serde(transparent)]
@ -57,27 +56,26 @@ impl KeymapFileContent {
for KeymapBlock { context, bindings } in self.0 {
let bindings = bindings
.into_iter()
.filter_map(|(keystroke, action)| {
.map(|(keystroke, action)| {
let action = action.0.get();
// This is a workaround for a limitation in serde: serde-rs/json#497
// We want to deserialize the action data as a `RawValue` so that we can
// deserialize the action itself dynamically directly from the JSON
// string. But `RawValue` currently does not work inside of an untagged enum.
if action.starts_with('[') {
let ActionWithData(name, data) = serde_json::from_str(action).log_err()?;
let action = if action.starts_with('[') {
let ActionWithData(name, data) = serde_json::from_str(action)?;
cx.deserialize_action(&name, Some(data.get()))
} else {
let name = serde_json::from_str(action).log_err()?;
let name = serde_json::from_str(action)?;
cx.deserialize_action(name, None)
}
.with_context(|| {
format!(
"invalid binding value for keystroke {keystroke}, context {context:?}"
)
})
.log_err()
.map(|action| Binding::load(&keystroke, action, context.as_deref()))
})?;
Binding::load(&keystroke, action, context.as_deref())
})
.collect::<Result<Vec<_>>>()?;