rules: Fix last_result not passed among chained rules
A previous refactor accidentally broke chained rules that rely on the
result chaining, so fix it.
With it fixed, some rule examples from docs/rules.md work properly
again, yay!
---
- Feature: THUMB WHEEL
- Rule: [ Modifiers: Control, Test: thumb_wheel_up, MouseScroll: [-2, 0] ]
- Rule:
- Modifiers: Control
- Test: thumb_wheel_down
- MouseScroll: [-2, 0]
- Rule: [ Or: [ Test: thumb_wheel_up, Test: thumb_wheel_down ], MouseScroll: [-1, 0] ]
...
---
- Feature: LOWRES WHEEL
- Rule: [ Or: [ Test: lowres_wheel_up, Test: lowres_wheel_down ], MouseScroll: [0, 2] ]
...
Fixes: 46366b2430 ("Fix warnings from automatic code inspections")
Signed-off-by: Rongrong <i@rong.moe>
This commit is contained in:
parent
b56f30d24d
commit
94cb282c77
|
|
@ -481,14 +481,13 @@ class RuleComponent:
|
|||
|
||||
|
||||
def _evaluate(components, feature, notification: HIDPPNotification, device, result) -> Any:
|
||||
res = True
|
||||
for component in components:
|
||||
res = component.evaluate(feature, notification, device, result)
|
||||
if not isinstance(component, Action) and res is None:
|
||||
result = component.evaluate(feature, notification, device, result)
|
||||
if not isinstance(component, Action) and result is None:
|
||||
return None
|
||||
if isinstance(component, Condition) and not res:
|
||||
return res
|
||||
return res
|
||||
if isinstance(component, Condition) and not result:
|
||||
return result
|
||||
return result
|
||||
|
||||
|
||||
class Rule(RuleComponent):
|
||||
|
|
|
|||
Loading…
Reference in New Issue