Skip to content

Commit

Permalink
fix: eagerly remove omission modifier after cartesian product
Browse files Browse the repository at this point in the history
  • Loading branch information
lavafroth committed Jul 22, 2024
1 parent 0aa67ff commit 87972b1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ fn binding_parser(pair: Pair<'_, Rule>) -> Result<Vec<Binding>, ParseError> {
return Err(Box::new(err).into());
}

let bindings = bind_cartesian_product
let mut bindings: Vec<Binding> = bind_cartesian_product
.into_iter()
.zip(command_cartesian_product)
.map(|(definition, command)| Binding {
Expand All @@ -435,5 +435,9 @@ fn binding_parser(pair: Pair<'_, Rule>) -> Result<Vec<Binding>, ParseError> {
.collect(),
})
.collect();

for binding in bindings.iter_mut() {
binding.definition.modifiers.remove(&Modifier::Omission);
}
Ok(bindings)
}
4 changes: 3 additions & 1 deletion src/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pub enum Modifier {
Control,
Shift,
Any,
Omission,
}

impl From<ModifierRepr> for Modifier {
Expand All @@ -37,7 +38,8 @@ impl From<ModifierRepr> for Modifier {
"mod5" => Modifier::Altgr,
"shift" => Modifier::Shift,
"any" => Modifier::Any,
_ => panic!("that's not a modifier"),
"_" => Modifier::Omission,
_ => panic!("{:?} is not a modifier", value),
}
}
}
Expand Down

0 comments on commit 87972b1

Please sign in to comment.